diff markup/core.py @ 73:b0fd16111f2e

Some more performance tweaks.
author cmlenz
date Wed, 12 Jul 2006 18:47:39 +0000
parents e9a3930f8823
children f1aa49c759b2
line wrap: on
line diff
--- a/markup/core.py
+++ b/markup/core.py
@@ -297,14 +297,13 @@
         as is. Escaping quotes is generally only required for strings that are
         to be used in attribute values.
         """
-        if isinstance(text, cls):
+        if not text:
+            return cls()
+        if type(text) is cls:
             return text
-        text = unicode(text)
-        if not text or isinstance(text, cls):
-            return cls()
-        text = text.replace('&', '&') \
-                   .replace('<', '&lt;') \
-                   .replace('>', '&gt;')
+        text = unicode(text).replace('&', '&amp;') \
+                            .replace('<', '&lt;') \
+                            .replace('>', '&gt;')
         if quotes:
             text = text.replace('"', '&#34;')
         return cls(text)
@@ -397,7 +396,6 @@
 
     def __getitem__(self, name):
         return QName(self.uri + u'}' + name)
-
     __getattr__ = __getitem__
 
     def __repr__(self):
Copyright (C) 2012-2017 Edgewall Software