Skip to content

Commit 8ce81cc

Browse files
authored
_check_encoding: Improve efficiency by creating dict outside the for loop (#3648)
1 parent a29d513 commit 8ce81cc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pygmt/helpers/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ def _check_encoding(argstr: str) -> Encoding:
188188
charset["ZapfDingbats"].values()
189189
)
190190
for encoding in ["ISOLatin1+"] + [f"ISO-8859-{i}" for i in range(1, 17) if i != 12]:
191-
if all(c in (set(charset[encoding].values()) | adobe_chars) for c in argstr):
191+
chars = set(charset[encoding].values()) | adobe_chars
192+
if all(c in chars for c in argstr):
192193
return encoding # type: ignore[return-value]
193194
# Return the "ISOLatin1+" encoding if the string contains characters from multiple
194195
# charset encodings or contains characters that are not in any charset encoding.

0 commit comments

Comments
 (0)