]> git.eshelyaron.com Git - emacs.git/commitdiff
allocate_vectorlike minor cleanup
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Dec 2017 02:17:00 +0000 (18:17 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Dec 2017 02:18:02 +0000 (18:18 -0800)
* src/alloc.c (allocate_vectorlike): Move a bit of code out of the
critical section.  Although this doesn’t really help performance,
it cleans up the code a bit and should make it easier to add
pointer bounds checking.

src/alloc.c

index 49c99501f112be2763516ef9be94ee548b93bf7f..4f3928a482434a935f6750618cb3aed67bab59ea 100644 (file)
@@ -3317,15 +3317,14 @@ sweep_vectors (void)
 static struct Lisp_Vector *
 allocate_vectorlike (ptrdiff_t len)
 {
-  struct Lisp_Vector *p;
-
-  MALLOC_BLOCK_INPUT;
-
   if (len == 0)
-    p = XVECTOR (zero_vector);
+    return XVECTOR (zero_vector);
   else
     {
       size_t nbytes = header_size + len * word_size;
+      struct Lisp_Vector *p;
+
+      MALLOC_BLOCK_INPUT;
 
 #ifdef DOUG_LEA_MALLOC
       if (!mmap_lisp_allowed_p ())
@@ -3355,11 +3354,11 @@ allocate_vectorlike (ptrdiff_t len)
 
       consing_since_gc += nbytes;
       vector_cells_consed += len;
-    }
 
-  MALLOC_UNBLOCK_INPUT;
+      MALLOC_UNBLOCK_INPUT;
 
-  return p;
+      return p;
+    }
 }