Spaces:
Running
Running
perf: optimize string operations in OpenAPI parameter processing (#1342)
Browse files
src/fastmcp/utilities/openapi.py
CHANGED
|
@@ -82,13 +82,9 @@ def format_array_parameter(
|
|
| 82 |
return values
|
| 83 |
else:
|
| 84 |
# For path parameters, fallback to string representation without Python syntax
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
.replace("]", "")
|
| 89 |
-
.replace("'", "")
|
| 90 |
-
.replace('"', "")
|
| 91 |
-
)
|
| 92 |
return str_value
|
| 93 |
|
| 94 |
|
|
|
|
| 82 |
return values
|
| 83 |
else:
|
| 84 |
# For path parameters, fallback to string representation without Python syntax
|
| 85 |
+
# Use str.translate() for efficient character removal
|
| 86 |
+
translation_table = str.maketrans("", "", "[]'\"")
|
| 87 |
+
str_value = str(values).translate(translation_table)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
return str_value
|
| 89 |
|
| 90 |
|