Rev 4077: Use intern() instead of _get_cached_ascii for getting unique revision_ids and file_ids. in lp:///~jameinel/bzr/intern_keys

John Arbash Meinel john at arbash-meinel.com
Wed Mar 4 02:54:19 GMT 2009


At lp:///~jameinel/bzr/intern_keys

------------------------------------------------------------
revno: 4077
revision-id: john at arbash-meinel.com-20090304025410-pzr7phpvarv25jea
parent: john at arbash-meinel.com-20090304025054-fze01hr79xjv21x5
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: intern_keys
timestamp: Tue 2009-03-03 20:54:10 -0600
message:
  Use intern() instead of _get_cached_ascii for getting unique revision_ids and file_ids.
  
  intern() puts the strings in a dict (similar to what we do), but it does so
  without increasing the refcount, so intern()ed strings do not have
  unlimited lifetime.
  This allows us to avoid duplicate copies in memory, without having an unlimited cache.
  Further, we avoid keeping a Unicode representation of the string around,
  as we no longer use unicode revision_ids or file_ids in the codebase.
-------------- next part --------------
=== modified file 'bzrlib/xml8.py'
--- a/bzrlib/xml8.py	2009-01-17 01:30:58 +0000
+++ b/bzrlib/xml8.py	2009-03-04 02:54:10 +0000
@@ -131,7 +131,7 @@
     if a_str.__class__ == unicode:
         return _encode_utf8(a_str)
     else:
-        return _get_cached_ascii(a_str)
+        return intern(a_str)
 
 
 def _clear_cache():



More information about the bazaar-commits mailing list