summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorDarrenJiang13 <yjjiang1996@163.com>2022-03-14 14:22:57 +0800
committerGitHub <noreply@github.com>2022-03-14 08:22:57 +0200
commit38ed6c600791f266cea1ba66f53674c605b7babb (patch)
tree1a3fd5084d073c39e8dab766f88ae358677b539e /src/util.h
parentdc7a9d3a3130e734e30076b3b0be70aa7f752272 (diff)
downloadredis-38ed6c600791f266cea1ba66f53674c605b7babb.tar.gz
improve string2ll() to avoid extra conversion for long integer string. (#10408)
For an integer string like "123456789012345678901" which could cause overflow-failure in string2ll() conversion, we could compare its length at the beginning to avoid extra work. * move LONG_STR_SIZE to be in declared in util.h, next to MAX_LONG_DOUBLE_CHARS
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 7dce8ff69..c81db5d16 100644
--- a/src/util.h
+++ b/src/util.h
@@ -38,6 +38,9 @@
* This should be the size of the buffer given to ld2string */
#define MAX_LONG_DOUBLE_CHARS 5*1024
+/* Bytes needed for long -> str + '\0' */
+#define LONG_STR_SIZE 21
+
/* long double to string conversion options */
typedef enum {
LD_STR_AUTO, /* %.17Lg */