[PATCH] CORE: array, reduce var declaration

Ranier Vilela ranier.vf at gmail.com
Sun Mar 1 19:57:48 UTC 2020


Hi,
Is it in the interest of the nginx team, patches that promote the reduction
of variable declaration?

regards,
Ranier Vilela

--- \dll\nginx-1.17.8\a\core\ngx_array.c 2020-01-21 10:39:42.000000000 -0300
+++ ngx_array.c 2020-03-01 10:51:56.769840300 -0300
@@ -48,10 +48,10 @@
 ngx_array_push(ngx_array_t *a)
 {
     void        *elt, *new;
-    size_t       size;
-    ngx_pool_t  *p;

     if (a->nelts == a->nalloc) {
+        size_t       size;
+        ngx_pool_t  *p;

         /* the array is full */

@@ -94,14 +94,13 @@
 void *
 ngx_array_push_n(ngx_array_t *a, ngx_uint_t n)
 {
-    void        *elt, *new;
+    void        *elt;
     size_t       size;
-    ngx_uint_t   nalloc;
-    ngx_pool_t  *p;

     size = n * a->size;

     if (a->nelts + n > a->nalloc) {
+        ngx_pool_t  *p;

         /* the array is full */

@@ -119,6 +118,9 @@
             a->nalloc += n;

         } else {
+            void        *new;
+            ngx_uint_t   nalloc;
+
             /* allocate a new array */

             nalloc = 2 * ((n >= a->nalloc) ? n : a->nalloc);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20200301/e9dae032/attachment.htm>


More information about the nginx-devel mailing list