~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/cache_utf8.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
# TODO: Some kind of command-line display of revision properties:
 
17
# TODO: Some kind of command-line display of revision properties: 
18
18
# perhaps show them in log -v and allow them as options to the commit command.
19
19
 
20
20
"""Some functions to enable caching the conversion between unicode to utf8"""
21
21
 
22
 
from __future__ import absolute_import
23
 
 
24
22
import codecs
25
23
 
26
 
_utf8_encode = codecs.utf_8_encode
27
 
_utf8_decode = codecs.utf_8_decode
 
24
 
 
25
_utf8_encode = codecs.getencoder("utf-8")
 
26
_utf8_decode = codecs.getdecoder("utf-8")
28
27
def _utf8_decode_with_None(bytestring, _utf8_decode=_utf8_decode):
29
28
    """wrap _utf8_decode to support None->None for optional strings.
30
29
 
50
49
    """Take this unicode revision id, and get a unicode version"""
51
50
    # If the key is in the cache try/KeyError is 50% faster than
52
51
    # val = dict.get(key), if val is None:
53
 
    # On jam's machine the difference is
54
 
    # try/KeyError:  900ms
55
 
    #      if None: 1250ms
 
52
    # On jam's machine the difference is 
 
53
    # try/KeyError:  900ms 
 
54
    #      if None: 1250ms 
56
55
    # Since these are primarily used when iterating over a knit entry
57
56
    # *most* of the time the key will already be in the cache, so use the
58
57
    # fast path