emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 1300568: Omit XLI (init) == 0 optimization in make-


From: Paul Eggert
Subject: [Emacs-diffs] master 1300568: Omit XLI (init) == 0 optimization in make-vector
Date: Fri, 05 Feb 2016 22:37:41 +0000

branch: master
commit 130056880fe9d807fbaee5bc5f68249ea9cf6438
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Omit XLI (init) == 0 optimization in make-vector
    
    * src/alloc.c (Fmake_vector): Simplify by omitting the (XLI (init)
    == 0) case, as this optimization is probably not worth the hassle.
    Just for the record, the test for that case could have been
    (XLI (init) % ((EMACS_UINT) -1 / UCHAR_MAX) == 0) (!),
    assuming the typical platform with no padding bits and where
    conversion to int omits the most significant bits.
---
 src/alloc.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 031c78c..92945bc 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3321,14 +3321,9 @@ See also the function `vector'.  */)
   (Lisp_Object length, Lisp_Object init)
 {
   CHECK_NATNUM (length);
-
   struct Lisp_Vector *p = allocate_vector (XFASTINT (length));
-  if (XLI (init) == 0)
-    memset (p->contents, 0, XFASTINT (length) * sizeof p->contents[0]);
-  else
-    for (ptrdiff_t i = 0; i < XFASTINT (length); i++)
-      p->contents[i] = init;
-
+  for (ptrdiff_t i = 0; i < XFASTINT (length); i++)
+    p->contents[i] = init;
   return make_lisp_ptr (p, Lisp_Vectorlike);
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]