summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-02-20 03:24:58 (GMT)
committerJason Evans <jasone@canonware.com>2016-02-20 04:32:37 (GMT)
commit4985dc681e2e44f9d43c902647371790acac3ad4 (patch)
treeabd920363e8d12586b97660f6f4d5532ace8fedd
parent578cd165812a11cd7250bfe5051cddc30ffec6e5 (diff)
downloadjemalloc-4985dc681e2e44f9d43c902647371790acac3ad4.zip
jemalloc-4985dc681e2e44f9d43c902647371790acac3ad4.tar.gz
jemalloc-4985dc681e2e44f9d43c902647371790acac3ad4.tar.bz2
Refactor arena_ralloc_no_move().
Refactor early return logic in arena_ralloc_no_move() to return early on failure rather than on success.
-rw-r--r--src/arena.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/arena.c b/src/arena.c
index b452df6..68220d7 100644
--- a/src/arena.c
+++ b/src/arena.c
@@ -2810,20 +2810,19 @@ arena_ralloc_no_move(void *ptr, size_t oldsize, size_t size, size_t extra,
if (oldsize <= SMALL_MAXCLASS) {
assert(arena_bin_info[size2index(oldsize)].reg_size ==
oldsize);
- if ((usize_max <= SMALL_MAXCLASS &&
- size2index(usize_max) == size2index(oldsize)) ||
- (size <= oldsize && usize_max >= oldsize))
- return (false);
+ if ((usize_max > SMALL_MAXCLASS ||
+ size2index(usize_max) != size2index(oldsize)) &&
+ (size > oldsize || usize_max < oldsize))
+ return (true);
} else {
- if (usize_max > SMALL_MAXCLASS) {
- if (!arena_ralloc_large(ptr, oldsize, usize_min,
- usize_max, zero))
- return (false);
- }
+ if (usize_max <= SMALL_MAXCLASS)
+ return (true);
+ if (arena_ralloc_large(ptr, oldsize, usize_min,
+ usize_max, zero))
+ return (true);
}
- /* Reallocation would require a move. */
- return (true);
+ return (false);
} else {
return (huge_ralloc_no_move(ptr, oldsize, usize_min, usize_max,
zero));