Bug 1413096 - Remove unnecessary call to ffs. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 30 Oct 2017 17:57:55 +0900
changeset 689163 ecb05844831d596f8acbfab734fba45999244828
parent 689162 56f5900a0c21c9107576bb2647e36fce22229185
child 689164 0b717b3bdb043c5d68d67e0f5d35baf47d695b1c
child 689173 87c4131213e81a2529e5013a12766abf6cd466e1
push id86942
push userbmo:mh+mozilla@glandium.org
push dateTue, 31 Oct 2017 06:24:30 +0000
reviewersnjn
bugs1413096
milestone58.0a1
Bug 1413096 - Remove unnecessary call to ffs. r?njn Comparing ffs(x) == ffs(y), when x and y are guaranteed to be powers of 2 (or 0, or 1), is the same as x == y.
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -3755,18 +3755,18 @@ static void*
 arena_ralloc(void* aPtr, size_t aSize, size_t aOldSize, arena_t* aArena)
 {
   void* ret;
   size_t copysize;
 
   // Try to avoid moving the allocation.
   if (aSize < small_min) {
     if (aOldSize < small_min &&
-        ffs((int)(RoundUpPow2(aSize) >> (TINY_MIN_2POW + 1))) ==
-          ffs((int)(RoundUpPow2(aOldSize) >> (TINY_MIN_2POW + 1)))) {
+        (RoundUpPow2(aSize) >> (TINY_MIN_2POW + 1) ==
+         RoundUpPow2(aOldSize) >> (TINY_MIN_2POW + 1))) {
       goto IN_PLACE; // Same size class.
     }
   } else if (aSize <= small_max) {
     if (aOldSize >= small_min && aOldSize <= small_max &&
         (QUANTUM_CEILING(aSize) >> QUANTUM_2POW_MIN) ==
           (QUANTUM_CEILING(aOldSize) >> QUANTUM_2POW_MIN)) {
       goto IN_PLACE; // Same size class.
     }