perf: optimize string operations in OpenAPI parameter processing (#1342)

This commit is contained in:
633WHU 2025-08-03 21:52:03 +08:00 committed by GitHub
commit 5ee159a4b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -82,13 +82,9 @@ def format_array_parameter(
return values
else:
# For path parameters, fallback to string representation without Python syntax
str_value = (
str(values)
.replace("[", "")
.replace("]", "")
.replace("'", "")
.replace('"', "")
)
# Use str.translate() for efficient character removal
translation_table = str.maketrans("", "", "[]'\"")
str_value = str(values).translate(translation_table)
return str_value