* alloc.c (allocate_vector_block): Remove redundant
authorDmitry Antipov <dmantipov@yandex.ru>
Tue, 3 Jul 2012 11:09:36 +0000 (15:09 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Tue, 3 Jul 2012 11:09:36 +0000 (15:09 +0400)
calls to mallopt if DOUG_LEA_MALLOC is defined.
(allocate_vectorlike): If DOUG_LEA_MALLOC is defined,
avoid calls to mallopt if zero_vector is returned.

src/ChangeLog
src/alloc.c

index d0dfa13..9861fe7 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-03  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * alloc.c (allocate_vector_block): Remove redundant
+       calls to mallopt if DOUG_LEA_MALLOC is defined.
+       (allocate_vectorlike): If DOUG_LEA_MALLOC is defined,
+       avoid calls to mallopt if zero_vector is returned.
+
 2012-07-03  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * alloc.c (check_string_bytes): If GC_CHECK_STRING_BYTES
index 3306bc4..0d4491e 100644 (file)
@@ -2958,17 +2958,7 @@ static struct Lisp_Vector *zero_vector;
 static struct vector_block *
 allocate_vector_block (void)
 {
-  struct vector_block *block;
-
-#ifdef DOUG_LEA_MALLOC
-  mallopt (M_MMAP_MAX, 0);
-#endif
-
-  block = xmalloc (sizeof (struct vector_block));
-
-#ifdef DOUG_LEA_MALLOC
-  mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);
-#endif
+  struct vector_block *block = xmalloc (sizeof (struct vector_block));
 
 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK
   mem_insert (block->data, block->data + VECTOR_BLOCK_BYTES,
@@ -3166,44 +3156,42 @@ static struct Lisp_Vector *
 allocate_vectorlike (ptrdiff_t len)
 {
   struct Lisp_Vector *p;
-  size_t nbytes;
 
   MALLOC_BLOCK_INPUT;
 
-#ifdef DOUG_LEA_MALLOC
-  /* Prevent mmap'ing the chunk.  Lisp data may not be mmap'ed
-     because mapped region contents are not preserved in
-     a dumped Emacs.  */
-  mallopt (M_MMAP_MAX, 0);
-#endif
-
   /* This gets triggered by code which I haven't bothered to fix.  --Stef  */
   /* eassert (!handling_signal); */
 
   if (len == 0)
+    p = zero_vector;
+  else
     {
-      MALLOC_UNBLOCK_INPUT;
-      return zero_vector;
-    }
+      size_t nbytes = header_size + len * word_size;
 
-  nbytes = header_size + len * word_size;
+#ifdef DOUG_LEA_MALLOC
+      /* Prevent mmap'ing the chunk.  Lisp data may not be mmap'ed
+        because mapped region contents are not preserved in
+        a dumped Emacs.  */
+      mallopt (M_MMAP_MAX, 0);
+#endif
 
-  if (nbytes <= VBLOCK_BYTES_MAX)
-    p = allocate_vector_from_block (vroundup (nbytes));
-  else
-    {
-      p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE);
-      p->header.next.vector = large_vectors;
-      large_vectors = p;
-    }
+      if (nbytes <= VBLOCK_BYTES_MAX)
+       p = allocate_vector_from_block (vroundup (nbytes));
+      else
+       {
+         p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE);
+         p->header.next.vector = large_vectors;
+         large_vectors = p;
+       }
 
 #ifdef DOUG_LEA_MALLOC
-  /* Back to a reasonable maximum of mmap'ed areas.  */
-  mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);
+      /* Back to a reasonable maximum of mmap'ed areas.  */
+      mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);
 #endif
 
-  consing_since_gc += nbytes;
-  vector_cells_consed += len;
+      consing_since_gc += nbytes;
+      vector_cells_consed += len;
+    }
 
   MALLOC_UNBLOCK_INPUT;