Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r46185:6df7a687dcae Date: 2011-08-01 21:41 +0200 http://bitbucket.org/pypy/pypy/changeset/6df7a687dcae/
Log: Simplify a bit, computing a "toobig" value in a way that is clearly constant-foldable, followed by a r_uint comparison. diff --git a/pypy/rpython/memory/gc/minimark.py b/pypy/rpython/memory/gc/minimark.py --- a/pypy/rpython/memory/gc/minimark.py +++ b/pypy/rpython/memory/gc/minimark.py @@ -517,13 +517,15 @@ # constant-folded because self.nonlarge_max, size and itemsize # are all constants (the arguments are constant due to # inlining). - too_many_items = raw_malloc_usage(nonvarsize) > self.nonlarge_max - if not too_many_items and raw_malloc_usage(itemsize) > 0: - maxlength = self.nonlarge_max - raw_malloc_usage(nonvarsize) - maxlength = maxlength // raw_malloc_usage(itemsize) - too_many_items = r_uint(length) > r_uint(maxlength) + maxsize = self.nonlarge_max - raw_malloc_usage(nonvarsize) + if maxsize < 0: + toobig = r_uint(0) # the nonvarsize alone is too big + elif raw_malloc_usage(itemsize): + toobig = r_uint(maxsize // raw_malloc_usage(itemsize)) + 1 + else: + toobig = r_uint(sys.maxint) + 1 - if too_many_items: + if r_uint(length) >= r_uint(toobig): # # If the total size of the object would be larger than # 'nonlarge_max', then allocate it externally. We also _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit