[nginx] Slab: style.

Ruslan Ermilov ru at nginx.com
Tue Jul 4 15:37:06 UTC 2017


details:   http://hg.nginx.org/nginx/rev/94f30939545a
branches:  
changeset: 7049:94f30939545a
user:      Ruslan Ermilov <ru at nginx.com>
date:      Tue Jul 04 18:32:28 2017 +0300
description:
Slab: style.

diffstat:

 src/core/ngx_slab.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (79 lines):

diff -r 80224192163c -r 94f30939545a src/core/ngx_slab.c
--- a/src/core/ngx_slab.c	Tue Jul 04 18:07:29 2017 +0300
+++ b/src/core/ngx_slab.c	Tue Jul 04 18:32:28 2017 +0300
@@ -181,8 +181,8 @@ void *
 ngx_slab_alloc_locked(ngx_slab_pool_t *pool, size_t size)
 {
     size_t            s;
-    uintptr_t         p, n, m, mask, *bitmap;
-    ngx_uint_t        i, slot, shift, map;
+    uintptr_t         p, m, mask, *bitmap;
+    ngx_uint_t        i, n, slot, shift, map;
     ngx_slab_page_t  *page, *prev, *slots;
 
     if (size > ngx_slab_max_size) {
@@ -226,7 +226,7 @@ ngx_slab_alloc_locked(ngx_slab_pool_t *p
 
             bitmap = (uintptr_t *) ngx_slab_page_addr(pool, page);
 
-            map = (ngx_pagesize >> shift) / (sizeof(uintptr_t) * 8);
+            map = (ngx_pagesize >> shift) / (8 * sizeof(uintptr_t));
 
             for (n = 0; n < map; n++) {
 
@@ -239,7 +239,7 @@ ngx_slab_alloc_locked(ngx_slab_pool_t *p
 
                         bitmap[n] |= m;
 
-                        i = (n * sizeof(uintptr_t) * 8 + i) << shift;
+                        i = (n * 8 * sizeof(uintptr_t) + i) << shift;
 
                         p = (uintptr_t) bitmap + i;
 
@@ -341,7 +341,7 @@ ngx_slab_alloc_locked(ngx_slab_pool_t *p
             /* "n" elements for bitmap, plus one requested */
             bitmap[0] = ((uintptr_t) 2 << n) - 1;
 
-            map = (ngx_pagesize >> shift) / (sizeof(uintptr_t) * 8);
+            map = (ngx_pagesize >> shift) / (8 * sizeof(uintptr_t));
 
             for (i = 1; i < map; i++) {
                 bitmap[i] = 0;
@@ -369,7 +369,7 @@ ngx_slab_alloc_locked(ngx_slab_pool_t *p
 
             slots[slot].next = page;
 
-            pool->stats[slot].total += sizeof(uintptr_t) * 8;
+            pool->stats[slot].total += 8 * sizeof(uintptr_t);
 
             p = ngx_slab_page_addr(pool, page);
 
@@ -480,8 +480,8 @@ ngx_slab_free_locked(ngx_slab_pool_t *po
         }
 
         n = ((uintptr_t) p & (ngx_pagesize - 1)) >> shift;
-        m = (uintptr_t) 1 << (n % (sizeof(uintptr_t) * 8));
-        n /= sizeof(uintptr_t) * 8;
+        m = (uintptr_t) 1 << (n % (8 * sizeof(uintptr_t)));
+        n /= 8 * sizeof(uintptr_t);
         bitmap = (uintptr_t *)
                              ((uintptr_t) p & ~((uintptr_t) ngx_pagesize - 1));
 
@@ -510,7 +510,7 @@ ngx_slab_free_locked(ngx_slab_pool_t *po
                 goto done;
             }
 
-            map = (ngx_pagesize >> shift) / (sizeof(uintptr_t) * 8);
+            map = (ngx_pagesize >> shift) / (8 * sizeof(uintptr_t));
 
             for (i = 1; i < map; i++) {
                 if (bitmap[i]) {
@@ -558,7 +558,7 @@ ngx_slab_free_locked(ngx_slab_pool_t *po
 
             ngx_slab_free_pages(pool, page, 1);
 
-            pool->stats[slot].total -= sizeof(uintptr_t) * 8;
+            pool->stats[slot].total -= 8 * sizeof(uintptr_t);
 
             goto done;
         }


More information about the nginx-devel mailing list