[Python-checkins] python/dist/src/Lib/xml/sax saxutils.py,1.17,1.18

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
Mon, 28 Oct 2002 09:29:05 -0800


Update of /cvsroot/python/python/dist/src/Lib/xml/sax
In directory usw-pr-cvs1:/tmp/cvs-serv20493

Modified Files:
	saxutils.py 
Log Message:
Avoid calling __dict_replace() if we don't need to -- the call is much
more expensive than just doing to work needed, and these things seem
to always turn into a bottleneck eventually.


Index: saxutils.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/saxutils.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** saxutils.py	26 Oct 2002 14:50:45 -0000	1.17
--- saxutils.py	28 Oct 2002 17:29:01 -0000	1.18
***************
*** 29,36 ****
      # must do ampersand first
      data = data.replace("&", "&")
!     data = __dict_replace(data, {"<" : "&lt;",
!                                  ">" : "&gt;",
!                                  })
!     return __dict_replace(data, entities)
  
  def unescape(data, entities={}):
--- 29,37 ----
      # must do ampersand first
      data = data.replace("&", "&amp;")
!     data = data.replace(">", "&gt;")
!     data = data.replace("<", "&lt;")
!     if entities:
!         data = __dict_replace(data, entities)
!     return data
  
  def unescape(data, entities={}):
***************
*** 41,50 ****
      strings; each key will be replaced with its corresponding value.
      """
!     data = __dict_replace(data, {"&lt;"  : "<",
!                                  "&gt;"  : ">",
!                                  })
      # must do ampersand last
      data = data.replace("&amp;", "&")
!     return __dict_replace(data, entities)
  
  def quoteattr(data, entities={}):
--- 42,52 ----
      strings; each key will be replaced with its corresponding value.
      """
!     data = data.replace("&lt;", "<")
!     data = data.replace("&gt;", ">")
      # must do ampersand last
      data = data.replace("&amp;", "&")
!     if entities:
!         data = __dict_replace(data, entities)
!     return data
  
  def quoteattr(data, entities={}):