diff options
| author | Paul Eggert | 2017-06-01 16:03:12 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-06-01 16:06:38 -0700 |
| commit | 178d0cb5f530e6d7eb36eb9987ff405c854ccdb3 (patch) | |
| tree | d5c8c63dc97ed4635b354bb16803cbfd1d953470 /lib | |
| parent | 53247108411a1e9d1aa5352c231fa049f3f918aa (diff) | |
| download | emacs-178d0cb5f530e6d7eb36eb9987ff405c854ccdb3.tar.gz emacs-178d0cb5f530e6d7eb36eb9987ff405c854ccdb3.zip | |
Improve performance by avoiding strtoumax
This made (string-to-number "10") 20% faster on my old desktop,
an AMD Phenom II X4 910e running Fedora 25 x86-64.
* admin/merge-gnulib (GNULIB_MODULES): Remove strtoumax.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lib/strtoul.c, lib/strtoull.c, lib/strtoumax.c, m4/strtoull.m4:
* m4/strtoumax.m4: Remove.
* src/editfns.c (str2num): New function.
(styled_format): Use it instead of strtoumax. Use ptrdiff_t
instead of uintmax_t. Check for integer overflow.
* src/lread.c (LEAD_INT, DOT_CHAR, TRAIL_INT, E_EXP):
Move to private scope and make them enums.
(string_to_number): Compute integer value directly during
first pass instead of revisiting it with strtoumax later.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gnulib.mk.in | 27 | ||||
| -rw-r--r-- | lib/strtoul.c | 19 | ||||
| -rw-r--r-- | lib/strtoull.c | 26 | ||||
| -rw-r--r-- | lib/strtoumax.c | 2 |
4 files changed, 1 insertions, 73 deletions
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index d23c2a57ec3..73d304307d4 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | # the same distribution terms as the rest of that program. | 21 | # the same distribution terms as the rest of that program. |
| 22 | # | 22 | # |
| 23 | # Generated by gnulib-tool. | 23 | # Generated by gnulib-tool. |
| 24 | # Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stat --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=tzset --avoid=unsetenv --avoid=utime --avoid=utime-h --gnu-make --makefile-name=gnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-leading-zeros count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub update-copyright utimens vla warnings | 24 | # Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stat --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=tzset --avoid=unsetenv --avoid=utime --avoid=utime-h --gnu-make --makefile-name=gnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-leading-zeros count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub update-copyright utimens vla warnings |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | MOSTLYCLEANFILES += core *.stackdump | 27 | MOSTLYCLEANFILES += core *.stackdump |
| @@ -905,7 +905,6 @@ gl_GNULIB_ENABLED_getdtablesize = @gl_GNULIB_ENABLED_getdtablesize@ | |||
| 905 | gl_GNULIB_ENABLED_getgroups = @gl_GNULIB_ENABLED_getgroups@ | 905 | gl_GNULIB_ENABLED_getgroups = @gl_GNULIB_ENABLED_getgroups@ |
| 906 | gl_GNULIB_ENABLED_secure_getenv = @gl_GNULIB_ENABLED_secure_getenv@ | 906 | gl_GNULIB_ENABLED_secure_getenv = @gl_GNULIB_ENABLED_secure_getenv@ |
| 907 | gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@ | 907 | gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@ |
| 908 | gl_GNULIB_ENABLED_strtoull = @gl_GNULIB_ENABLED_strtoull@ | ||
| 909 | gl_GNULIB_ENABLED_tempname = @gl_GNULIB_ENABLED_tempname@ | 908 | gl_GNULIB_ENABLED_tempname = @gl_GNULIB_ENABLED_tempname@ |
| 910 | gl_LIBOBJS = @gl_LIBOBJS@ | 909 | gl_LIBOBJS = @gl_LIBOBJS@ |
| 911 | gl_LTLIBOBJS = @gl_LTLIBOBJS@ | 910 | gl_LTLIBOBJS = @gl_LTLIBOBJS@ |
| @@ -2507,30 +2506,6 @@ EXTRA_libgnu_a_SOURCES += strtol.c strtoll.c | |||
| 2507 | endif | 2506 | endif |
| 2508 | ## end gnulib module strtoll | 2507 | ## end gnulib module strtoll |
| 2509 | 2508 | ||
| 2510 | ## begin gnulib module strtoull | ||
| 2511 | ifeq (,$(OMIT_GNULIB_MODULE_strtoull)) | ||
| 2512 | |||
| 2513 | ifneq (,$(gl_GNULIB_ENABLED_strtoull)) | ||
| 2514 | |||
| 2515 | endif | ||
| 2516 | EXTRA_DIST += strtol.c strtoul.c strtoull.c | ||
| 2517 | |||
| 2518 | EXTRA_libgnu_a_SOURCES += strtol.c strtoul.c strtoull.c | ||
| 2519 | |||
| 2520 | endif | ||
| 2521 | ## end gnulib module strtoull | ||
| 2522 | |||
| 2523 | ## begin gnulib module strtoumax | ||
| 2524 | ifeq (,$(OMIT_GNULIB_MODULE_strtoumax)) | ||
| 2525 | |||
| 2526 | |||
| 2527 | EXTRA_DIST += strtoimax.c strtoumax.c | ||
| 2528 | |||
| 2529 | EXTRA_libgnu_a_SOURCES += strtoimax.c strtoumax.c | ||
| 2530 | |||
| 2531 | endif | ||
| 2532 | ## end gnulib module strtoumax | ||
| 2533 | |||
| 2534 | ## begin gnulib module symlink | 2509 | ## begin gnulib module symlink |
| 2535 | ifeq (,$(OMIT_GNULIB_MODULE_symlink)) | 2510 | ifeq (,$(OMIT_GNULIB_MODULE_symlink)) |
| 2536 | 2511 | ||
diff --git a/lib/strtoul.c b/lib/strtoul.c deleted file mode 100644 index c4974e069e5..00000000000 --- a/lib/strtoul.c +++ /dev/null | |||
| @@ -1,19 +0,0 @@ | |||
| 1 | /* Copyright (C) 1991, 1997, 2009-2017 Free Software Foundation, Inc. | ||
| 2 | This file is part of the GNU C Library. | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation; either version 3 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 16 | |||
| 17 | #define UNSIGNED 1 | ||
| 18 | |||
| 19 | #include "strtol.c" | ||
diff --git a/lib/strtoull.c b/lib/strtoull.c deleted file mode 100644 index 51ae3acb03c..00000000000 --- a/lib/strtoull.c +++ /dev/null | |||
| @@ -1,26 +0,0 @@ | |||
| 1 | /* Function to parse an 'unsigned long long int' from text. | ||
| 2 | Copyright (C) 1995-1997, 1999, 2009-2017 Free Software Foundation, Inc. | ||
| 3 | NOTE: The canonical source of this file is maintained with the GNU C | ||
| 4 | Library. Bugs can be reported to bug-glibc@gnu.org. | ||
| 5 | |||
| 6 | This program is free software: you can redistribute it and/or modify it | ||
| 7 | under the terms of the GNU General Public License as published by the | ||
| 8 | Free Software Foundation; either version 3 of the License, or any | ||
| 9 | later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 18 | |||
| 19 | #define QUAD 1 | ||
| 20 | |||
| 21 | #include "strtoul.c" | ||
| 22 | |||
| 23 | #ifdef _LIBC | ||
| 24 | strong_alias (__strtoull_internal, __strtouq_internal) | ||
| 25 | weak_alias (strtoull, strtouq) | ||
| 26 | #endif | ||
diff --git a/lib/strtoumax.c b/lib/strtoumax.c deleted file mode 100644 index dc395d626ab..00000000000 --- a/lib/strtoumax.c +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | #define UNSIGNED 1 | ||
| 2 | #include "strtoimax.c" | ||