chiliu commited on
Commit
86d067d
·
unverified ·
1 Parent(s): dd358c0

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

Browse files
Files changed (1) hide show
  1. src/fastmcp/utilities/openapi.py +3 -7
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
- str_value = (
86
- str(values)
87
- .replace("[", "")
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