Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74ff857

Browse files
committed
Speed improvement initializing mathtext parser.
svn path=/trunk/matplotlib/; revision=4387
1 parent 68644fa commit 74ff857

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

lib/matplotlib/pyparsing.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,22 +2845,18 @@ def oneOf( strs, caseless=False, useRegex=True ):
28452845
else:
28462846
warnings.warn("Invalid argument to oneOf, expected string or list",
28472847
SyntaxWarning, stacklevel=2)
2848-
2848+
2849+
symbols.sort(reverse=True)
28492850
i = 0
28502851
while i < len(symbols)-1:
28512852
cur = symbols[i]
2852-
for j,other in enumerate(symbols[i+1:]):
2853+
for j, other in enumerate(symbols[i+1:]):
28532854
if ( isequal(other, cur) ):
28542855
del symbols[i+j+1]
2856+
else:
28552857
break
2856-
elif ( masks(cur, other) ):
2857-
del symbols[i+j+1]
2858-
symbols.insert(i,other)
2859-
cur = other
2860-
break
2861-
else:
2862-
i += 1
2863-
2858+
i += 1
2859+
28642860
if not caseless and useRegex:
28652861
#~ print strs,"->", "|".join( [ _escapeRegexChars(sym) for sym in symbols] )
28662862
try:

0 commit comments

Comments
 (0)