From 8a2a5b0fb18841148e8648af095af6c5394bdd15 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 14 Dec 2017 09:12:03 -0500 Subject: [PATCH] avoid slowdown generating smart_filter --- awx/main/utils/filters.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/awx/main/utils/filters.py b/awx/main/utils/filters.py index 5442a329a1..2310361f88 100644 --- a/awx/main/utils/filters.py +++ b/awx/main/utils/filters.py @@ -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('"')