diff options
author | thatch <devnull@localhost> | 2008-08-14 23:39:04 -0700 |
---|---|---|
committer | thatch <devnull@localhost> | 2008-08-14 23:39:04 -0700 |
commit | 424366452ddc8619e89d3580aefb59e2bfae26b0 (patch) | |
tree | 5e6ebe5fc05e5b573c6e5154bd96621f693025e2 /pygments/util.py | |
parent | e6e3faecd77f18ba8977ea1f8832578d683f5930 (diff) | |
parent | 3e1d51e070744961d57aba8b7b2110e3ecaddacf (diff) | |
download | pygments-424366452ddc8619e89d3580aefb59e2bfae26b0.tar.gz |
Merge Scala support from Krzysiek Goj's branch
Diffstat (limited to 'pygments/util.py')
-rw-r--r-- | pygments/util.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/pygments/util.py b/pygments/util.py index 8232964c..0e8c952a 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -179,11 +179,18 @@ def html_doctype_matches(text): return doctype_matches(text, r'html\s+PUBLIC\s+"-//W3C//DTD X?HTML.*') +_looks_like_xml_cache = {} def looks_like_xml(text): """ Check if a doctype exists or if we have some tags. """ - m = doctype_lookup_re.match(text) - if m is not None: - return True - return tag_re.search(text) is not None + key = hash(text) + try: + return _looks_like_xml_cache[key] + except KeyError: + m = doctype_lookup_re.match(text) + if m is not None: + return True + rv = tag_re.search(text[:1000]) is not None + _looks_like_xml_cache[key] = rv + return rv |