Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e5b7a215
Commit
e5b7a215
authored
May 11, 2010
by
antirez
Browse files
hand written code to turn a long long into a string -> very big speed win
parent
bf028098
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
e5b7a215
...
@@ -2897,7 +2897,19 @@ static robj *createStringObjectFromLongLong(long long value) {
...
@@ -2897,7 +2897,19 @@ static robj *createStringObjectFromLongLong(long long value) {
o
->
encoding
=
REDIS_ENCODING_INT
;
o
->
encoding
=
REDIS_ENCODING_INT
;
o
->
ptr
=
(
void
*
)((
long
)
value
);
o
->
ptr
=
(
void
*
)((
long
)
value
);
}
else
{
}
else
{
o
->
ptr
=
sdscatprintf
(
sdsempty
(),
"%lld"
,
value
);
char
buf
[
32
],
*
p
;
char
*
c
=
"0123456789"
;
unsigned
long
v
;
v
=
(
value
<
0
)
?
-
value
:
value
;
p
=
buf
+
31
;
/* point to the last character */
while
(
v
)
{
*
p
--
=
c
[
v
%
10
];
v
/=
10
;
}
if
(
value
<
0
)
*
p
--
=
'-'
;
p
++
;
o
=
createObject
(
REDIS_STRING
,
sdsnewlen
(
p
,
32
-
(
p
-
buf
+
1
)));
}
}
}
}
return
o
;
return
o
;
...
@@ -3794,7 +3806,7 @@ static robj *rdbLoadIntegerObject(FILE *fp, int enctype) {
...
@@ -3794,7 +3806,7 @@ static robj *rdbLoadIntegerObject(FILE *fp, int enctype) {
val
=
0
;
/* anti-warning */
val
=
0
;
/* anti-warning */
redisPanic
(
"Unknown RDB integer encoding type"
);
redisPanic
(
"Unknown RDB integer encoding type"
);
}
}
return
create
Object
(
REDIS_STRING
,
sdscatprintf
(
sdsempty
(),
"%lld"
,
val
)
)
;
return
create
StringObjectFromLongLong
(
val
);
}
}
static
robj
*
rdbLoadLzfStringObject
(
FILE
*
fp
)
{
static
robj
*
rdbLoadLzfStringObject
(
FILE
*
fp
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment