[Python-checkins] cpython: The previous code is correct, but hard to verify: The libmpdec documentation
stefan.krah
python-checkins at python.org
Wed Apr 18 19:02:18 CEST 2012
http://hg.python.org/cpython/rev/7921a22b72f4
changeset: 76398:7921a22b72f4
user: Stefan Krah <skrah at bytereef.org>
date: Wed Apr 18 17:48:34 2012 +0200
summary:
The previous code is correct, but hard to verify: The libmpdec documentation
rightfully states that an mpd_t with a coefficient flagged as MPD_CONST_DATA
must not be in the position of the result operand. In this particular case
several assumptions guarantee that a resize will never occur in all possible
code paths, which was the reason for using MPD_CONST_DATA and saving an
instruction by omitting the initialization of tmp.alloc.
For readability, tmp is now flagged as MPD_STATIC_DATA and tmp.alloc
is initialized.
files:
Modules/_decimal/libmpdec/mpdecimal.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c
--- a/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/Modules/_decimal/libmpdec/mpdecimal.c
@@ -1280,7 +1280,8 @@
/* At this point a->digits+a->exp <= MPD_RDIGITS+1,
* so the shift fits. */
tmp.data = tmp_data;
- tmp.flags = MPD_STATIC|MPD_CONST_DATA;
+ tmp.flags = MPD_STATIC|MPD_STATIC_DATA;
+ tmp.alloc = 2;
mpd_qsshiftr(&tmp, a, -a->exp);
tmp.exp = 0;
a = &tmp;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list