avoid slowdown generating smart_filter

This commit is contained in:
AlanCoding 2017-12-14 09:12:03 -05:00
parent 2fb0144914
commit 8a2a5b0fb1
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B

View File

@ -1,5 +1,4 @@
import re
import sys
from pyparsing import (
infixNotation,
opAssoc,
@ -15,9 +14,6 @@ from awx.main.utils.common import get_search_fields
__all__ = ['SmartFilter']
unicode_spaces = [unichr(c) for c in xrange(sys.maxunicode) if unichr(c).isspace()]
unicode_spaces_other = unicode_spaces + [u'(', u')', u'=', u'"']
def string_to_type(t):
if t == u'true':
@ -213,6 +209,8 @@ class SmartFilter(object):
filter_string_raw = filter_string
filter_string = unicode(filter_string)
unicode_spaces = list(set(unicode(c) for c in filter_string if c.isspace()))
unicode_spaces_other = unicode_spaces + [u'(', u')', u'=', u'"']
atom = CharsNotIn(unicode_spaces_other)
atom_inside_quotes = CharsNotIn(u'"')
atom_quoted = Literal('"') + Optional(atom_inside_quotes) + Literal('"')