refactor: use the built-in max/min to simplify the code (#6272)

Signed-off-by: xiaoxiangirl <caojiaqiao@outlook.com>
This commit is contained in:
曹家巧 2025-06-24 08:19:06 +08:00 committed by GitHub
parent 695a7520b9
commit 4ff80784ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 8 deletions

View File

@ -829,10 +829,7 @@ func (h *httpPaths) Execute(filepath string) error {
} }
if len(expected) > len(actual) { if len(expected) > len(actual) {
actualValuesIndex := len(actual) - 1 actualValuesIndex := max(len(actual)-1, 0)
if actualValuesIndex < 0 {
actualValuesIndex = 0
}
return fmt.Errorf("missing values : %v", expected[actualValuesIndex:]) return fmt.Errorf("missing values : %v", expected[actualValuesIndex:])
} else if len(expected) < len(actual) { } else if len(expected) < len(actual) {
return fmt.Errorf("unexpected values : %v", actual[len(expected)-1:]) return fmt.Errorf("unexpected values : %v", actual[len(expected)-1:])

View File

@ -336,11 +336,8 @@ func (request *Request) executeTurboHTTP(input *contextargs.Context, dynamicValu
pipeClient := rawhttp.NewPipelineClient(pipeOptions) pipeClient := rawhttp.NewPipelineClient(pipeOptions)
// defaultMaxWorkers should be a sufficient value to keep queues always full // defaultMaxWorkers should be a sufficient value to keep queues always full
maxWorkers := defaultMaxWorkers
// in case the queue is bigger increase the workers // in case the queue is bigger increase the workers
if pipeOptions.MaxPendingRequests > maxWorkers { maxWorkers := max(pipeOptions.MaxPendingRequests, defaultMaxWorkers)
maxWorkers = pipeOptions.MaxPendingRequests
}
// Stop-at-first-match logic while executing requests // Stop-at-first-match logic while executing requests
// parallely using threads // parallely using threads