mirror of
https://github.com/danielmiessler/fabric.git
synced 2026-09-10 07:36:44 -04:00
Merge pull request #1875 from ksylvan/kayvan/modernize-part2-loops
modernize: update benchmarks to use b.Loop and refactor map copying
This commit is contained in:
commit
3a69437790
5
cmd/generate_changelog/incoming/1875.txt
Normal file
5
cmd/generate_changelog/incoming/1875.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
### PR [#1875](https://github.com/danielmiessler/Fabric/pull/1875) by [ksylvan](https://github.com/ksylvan): modernize: update benchmarks to use b.Loop and refactor map copying
|
||||
|
||||
- Updated benchmark loops to use cleaner `b.Loop()` syntax
|
||||
- Removed unnecessary `b.ResetTimer()` call in token benchmark
|
||||
- Used `maps.Copy` for merging variables in patterns handler
|
||||
|
|
@ -416,7 +416,7 @@ func TestGetValidTokenWithValidToken(t *testing.T) {
|
|||
|
||||
// Benchmark tests
|
||||
func BenchmarkGeneratePKCE(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for b.Loop() {
|
||||
_, _, err := generatePKCE()
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
|
|
@ -427,8 +427,7 @@ func BenchmarkGeneratePKCE(b *testing.B) {
|
|||
func BenchmarkTokenIsExpired(b *testing.B) {
|
||||
token := createTestToken("access", "refresh", 3600)
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for b.Loop() {
|
||||
token.IsExpired(5)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package restapi
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"net/http"
|
||||
|
||||
"github.com/danielmiessler/fabric/internal/plugins/db/fsdb"
|
||||
|
|
@ -74,9 +75,7 @@ func (h *PatternsHandler) ApplyPattern(c *gin.Context) {
|
|||
variables[key] = values[0]
|
||||
}
|
||||
}
|
||||
for key, value := range request.Variables {
|
||||
variables[key] = value
|
||||
}
|
||||
maps.Copy(variables, request.Variables)
|
||||
|
||||
pattern, err := h.patterns.GetApplyVariables(name, variables, request.Input)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue