/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/cache_utf8.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-10 00:57:21 UTC
  • mto: This revision was merged to the branch mainline in revision 1926.
  • Revision ID: john@arbash-meinel.com-20060810005721-1b6bd36c6078e519
Update cache tests, add a function to do something like intern() only for unicode objects

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        return unicode_str
52
52
 
53
53
 
 
54
def get_cached_unicode(unicode_str):
 
55
    """Return a cached version of the unicode string.
 
56
 
 
57
    This has a similar idea to that of intern() in that it tries
 
58
    to return a singleton string. Only it works for unicode strings.
 
59
    """
 
60
    # This might return the same object, or it might return the cached one
 
61
    # the decode() should just be a hash lookup, because the encode() side
 
62
    # should add the entry to the maps
 
63
    return decode(encode(unicode_str))
 
64
 
 
65
 
54
66
def clear_encoding_cache():
55
67
    """Clear the encoding and decoding caches"""
56
68
    global _unicode_to_utf8_map, _utf8_to_unicode_map