summaryrefslogtreecommitdiff
path: root/bs4/dammit.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2013-06-03 09:32:03 -0400
committerLeonard Richardson <leonard.richardson@canonical.com>2013-06-03 09:32:03 -0400
commit6c17512606b38171d7ea6aa645754d90b38f7324 (patch)
treeec21f0dc5a95cdf80dd0cdb10fa25eaf839e3e52 /bs4/dammit.py
parent8b110fa31859a7a9c0ea527d6a06d721b85a6a0e (diff)
downloadbeautifulsoup4-6c17512606b38171d7ea6aa645754d90b38f7324.tar.gz
Inlined some commonly called code to save a function call.
Diffstat (limited to 'bs4/dammit.py')
-rw-r--r--bs4/dammit.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bs4/dammit.py b/bs4/dammit.py
index a6b8663..c859066 100644
--- a/bs4/dammit.py
+++ b/bs4/dammit.py
@@ -295,15 +295,15 @@ class EncodingDetector:
beginning of the document.
"""
if search_entire_document:
- xml_endpos = html_endpos = -1
+ xml_endpos = html_endpos = len(markup)
else:
- xml_endpos = 1025
+ xml_endpos = 1024
html_endpos = max(2048, int(len(markup) * 0.05))
declared_encoding = None
- declared_encoding_match = xml_encoding_re.search(markup, xml_endpos)
+ declared_encoding_match = xml_encoding_re.search(markup, endpos=xml_endpos)
if not declared_encoding_match and is_html:
- declared_encoding_match = html_meta_re.search(markup, html_endpos)
+ declared_encoding_match = html_meta_re.search(markup, endpos=html_endpos)
if declared_encoding_match is not None:
declared_encoding = declared_encoding_match.groups()[0].decode(
'ascii')