diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-04-27 18:03:26 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-04-27 18:03:26 (GMT) |
commit | 602f740bc2da44ce25c22b7b4b5a7a4fb3435a5a (patch) | |
tree | 9c9f5c81767cd3ea9701ade84fea16144f2b56cd /Modules/linuxaudiodev.c | |
parent | 73364e64e5db0a0c79102471ebbd81d2607ec706 (diff) | |
download | cpython-602f740bc2da44ce25c22b7b4b5a7a4fb3435a5a.zip cpython-602f740bc2da44ce25c22b7b4b5a7a4fb3435a5a.tar.gz cpython-602f740bc2da44ce25c22b7b4b5a7a4fb3435a5a.tar.bz2 |
SF patch 549375: Compromise PyUnicode_EncodeUTF8
This implements ideas from Marc-Andre, Martin, Guido and me on Python-Dev.
"Short" Unicode strings are encoded into a "big enough" stack buffer,
then exactly as much string space as they turn out to need is allocated
at the end. This should have speed benefits akin to Martin's "measure
once, allocate once" strategy, but without needing a distinct measuring
pass.
"Long" Unicode strings allocate as much heap space as they could possibly
need (4 x # Unicode chars), and do a realloc at the end to return the
untouched excess. Since the overallocation is likely to be substantial,
this shouldn't burden the platform realloc with unusably small excess
blocks.
Also simplified uses of the PyString_xyz functions. Also added a release-
build check that 4*size doesn't overflow a C int. Sooner or later, that's
going to happen.
Diffstat (limited to 'Modules/linuxaudiodev.c')
0 files changed, 0 insertions, 0 deletions