Commit 25925687f728f1f3a8b29984f35ff8ba7d0f6cdf

Authored by Georg Hopp
1 parent 5e1c8f73

another small optimization

Showing 1 changed file with 5 additions and 3 deletions
@@ -748,14 +748,16 @@ TR_malloc(size_t size) @@ -748,14 +748,16 @@ TR_malloc(size_t size)
748 if (size < 8) { 748 if (size < 8) {
749 size = 8; 749 size = 8;
750 } else { 750 } else {
751 - size_t check = size;  
752 - size_t mask = 1; 751 + size_t check = size >> 4;
  752 + size_t mask = 0x1F;
753 753
754 while (check >>= 1) { 754 while (check >>= 1) {
755 mask = (mask << 1) | 1; 755 mask = (mask << 1) | 1;
756 } 756 }
757 757
758 - size = (size << 1) & ~mask; 758 + if (size != (size & ~(mask >> 1))) {
  759 + size = (size << 1) & ~mask;
  760 + }
759 } 761 }
760 } 762 }
761 763
Please register or login to post a comment