perf(claude): pre-allocate reverseMap capacity

Address Gemini code review suggestion: the reverseMap can contain at
most len(oauthToolRenameMap) entries, so pre-allocating avoids
reallocations as entries are added.
This commit is contained in:
edlsh
2026-04-18 12:49:02 -04:00
parent e707cf7d46
commit 03ea4e569f

View File

@@ -1018,7 +1018,7 @@ func isClaudeOAuthToken(apiKey string) bool {
// Amp's `glob`→`Glob`), because the global reverse map contained `Bash`→`bash`
// regardless of what the client originally sent.
func remapOAuthToolNames(body []byte) ([]byte, map[string]string) {
reverseMap := make(map[string]string)
reverseMap := make(map[string]string, len(oauthToolRenameMap))
recordRename := func(original, renamed string) {
// Preserve the first-seen original name if the same upstream name is
// produced from multiple call sites; they all map back identically.