Revision: 26f4728ade8d
Author:   Mikko Korpela <[email protected]>
Date:     Sun Jun 12 14:23:20 2011
Log: htmlutils: Add fast html_escape function with no formatting and no whitespace replace -- based on rebot profiling reduces reporting time by 20%
http://code.google.com/p/robotframework/source/detail?r=26f4728ade8d

Modified:
 /src/robot/serializing/jsparser.py
 /src/robot/utils/__init__.py
 /src/robot/utils/htmlutils.py

=======================================
--- /src/robot/serializing/jsparser.py  Fri Jun 10 13:50:23 2011
+++ /src/robot/serializing/jsparser.py  Sun Jun 12 14:23:20 2011
@@ -413,7 +413,7 @@
         if self._is_html:
             self._msg += [self._context.get_text_id(text)]
         else:
- self._msg += [self._context.get_text_id(utils.html_escape(text, replace_whitespace=False))] + self._msg += [self._context.get_text_id(utils.html_escape_no_formatting_no_whitespace_replace(text))]


 class _RootHandler(_Handler):
=======================================
--- /src/robot/utils/__init__.py        Fri Apr 15 13:29:35 2011
+++ /src/robot/utils/__init__.py        Sun Jun 12 14:23:20 2011
@@ -19,7 +19,7 @@
 from error import (get_error_message, get_error_details, ErrorDetails,
                    RERAISED_EXCEPTIONS)
 from escaping import escape, unescape
-from htmlutils import html_escape, html_attr_escape
+from htmlutils import html_escape, html_attr_escape, html_escape_no_formatting_no_whitespace_replace
 from htmlwriter import HtmlWriter
 from idgenerator import IdGenerator, FileNameGenerator
 from importing import simple_import, import_
=======================================
--- /src/robot/utils/htmlutils.py       Fri Jun 10 11:26:27 2011
+++ /src/robot/utils/htmlutils.py       Sun Jun 12 14:23:20 2011
@@ -54,6 +54,12 @@
         formatter.add(line)
     return formatter.result()

+def html_escape_no_formatting_no_whitespace_replace(text):
+    text = unic(text)
+    for name, value in [('&', '&amp;'), ('<', '&lt;'), ('>', '&gt;')]:
+        text = text.replace(name, value)
+    return _url_re.sub(lambda res: _repl_url(res, False), text)
+

 class _HtmlStringFormatter(object):

Reply via email to