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
1b4f8881
"doc/TwitterAlikeExample.html" did not exist on "37be27653817f0c4c18d695ceea082e0bb7bf462"
Commit
1b4f8881
authored
Sep 30, 2019
by
Oran Agra
Browse files
Use sdscatfmt instead of sdscatprintf in module info
sdscatfmt is faster
parent
d5c14c70
Changes
1
Show whitespace changes
Inline
Side-by-side
src/module.c
View file @
1b4f8881
...
...
@@ -4824,7 +4824,7 @@ int RM_InfoEndDictField(RedisModuleInfoCtx *ctx);
int
RM_InfoAddSection
(
RedisModuleInfoCtx
*
ctx
,
char
*
name
)
{
sds
full_name
=
sdsdup
(
ctx
->
module
->
name
);
if
(
name
!=
NULL
&&
strlen
(
name
)
>
0
)
full_name = sdscat
printf
(full_name, "_%s", name);
full_name
=
sdscat
fmt
(
full_name
,
"_%s"
,
name
);
/* Implicitly end dicts, instead of returning an error which is likely un checked. */
if
(
ctx
->
in_dict_field
)
...
...
@@ -4843,7 +4843,7 @@ int RM_InfoAddSection(RedisModuleInfoCtx *ctx, char *name) {
}
}
if
(
ctx
->
sections
++
)
ctx
->
info
=
sdscat
(
ctx
->
info
,
"
\r\n
"
);
ctx->info = sdscat
printf
(ctx->info, "# %
s
\r\n", full_name);
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"# %
S
\r\n
"
,
full_name
);
ctx
->
in_section
=
1
;
sdsfree
(
full_name
);
return
REDISMODULE_OK
;
...
...
@@ -4858,7 +4858,7 @@ int RM_InfoBeginDictField(RedisModuleInfoCtx *ctx, char *name) {
/* Implicitly end dicts, instead of returning an error which is likely un checked. */
if
(
ctx
->
in_dict_field
)
RM_InfoEndDictField
(
ctx
);
ctx->info = sdscat
printf
(ctx->info,
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s_%s:"
,
ctx
->
module
->
name
,
name
);
...
...
@@ -4873,7 +4873,7 @@ int RM_InfoEndDictField(RedisModuleInfoCtx *ctx) {
/* trim the last ',' if found. */
if
(
ctx
->
info
[
sdslen
(
ctx
->
info
)
-
1
]
==
','
)
sdsIncrLen
(
ctx
->
info
,
-
1
);
ctx->info = sdscat
printf
(ctx->info, "\r\n");
ctx
->
info
=
sdscat
(
ctx
->
info
,
"
\r\n
"
);
ctx
->
in_dict_field
=
0
;
return
REDISMODULE_OK
;
}
...
...
@@ -4885,14 +4885,14 @@ int RM_InfoAddFieldString(RedisModuleInfoCtx *ctx, char *field, RedisModuleStrin
if
(
!
ctx
->
in_section
)
return
REDISMODULE_ERR
;
if
(
ctx
->
in_dict_field
)
{
ctx->info = sdscat
printf
(ctx->info,
"%s=%
s
,",
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s=%
S
,"
,
field
,
(
sds
)
value
->
ptr
);
return
REDISMODULE_OK
;
}
ctx->info = sdscat
printf
(ctx->info,
"%s_%s:%
s
\r\n",
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s_%s:%
S
\r\n
"
,
ctx
->
module
->
name
,
field
,
(
sds
)
value
->
ptr
);
...
...
@@ -4903,13 +4903,13 @@ int RM_InfoAddFieldCString(RedisModuleInfoCtx *ctx, char *field, char *value) {
if
(
!
ctx
->
in_section
)
return
REDISMODULE_ERR
;
if
(
ctx
->
in_dict_field
)
{
ctx->info = sdscat
printf
(ctx->info,
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s=%s,"
,
field
,
value
);
return
REDISMODULE_OK
;
}
ctx->info = sdscat
printf
(ctx->info,
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s_%s:%s
\r\n
"
,
ctx
->
module
->
name
,
field
,
...
...
@@ -4939,14 +4939,14 @@ int RM_InfoAddFieldLongLong(RedisModuleInfoCtx *ctx, char *field, long long valu
if
(
!
ctx
->
in_section
)
return
REDISMODULE_ERR
;
if
(
ctx
->
in_dict_field
)
{
ctx->info = sdscat
printf
(ctx->info,
"%s=%
lld
,",
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s=%
I
,"
,
field
,
value
);
return
REDISMODULE_OK
;
}
ctx->info = sdscat
printf
(ctx->info,
"%s_%s:%
lld
\r\n",
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s_%s:%
I
\r\n
"
,
ctx
->
module
->
name
,
field
,
value
);
...
...
@@ -4957,14 +4957,14 @@ int RM_InfoAddFieldULongLong(RedisModuleInfoCtx *ctx, char *field, unsigned long
if
(
!
ctx
->
in_section
)
return
REDISMODULE_ERR
;
if
(
ctx
->
in_dict_field
)
{
ctx->info = sdscat
printf
(ctx->info,
"%s=%
llu
,",
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s=%
U
,"
,
field
,
value
);
return
REDISMODULE_OK
;
}
ctx->info = sdscat
printf
(ctx->info,
"%s_%s:%
llu
\r\n",
ctx
->
info
=
sdscat
fmt
(
ctx
->
info
,
"%s_%s:%
U
\r\n
"
,
ctx
->
module
->
name
,
field
,
value
);
...
...
@@ -5712,9 +5712,9 @@ sds genModulesInfoString(sds info) {
sds
usedby
=
genModulesInfoStringRenderModulesList
(
module
->
usedby
);
sds
using
=
genModulesInfoStringRenderModulesList
(
module
->
using
);
sds
options
=
genModulesInfoStringRenderModuleOptions
(
module
);
info = sdscat
printf
(info,
"module:name=%
s
,ver=%
d
,api=%
d
,filters=%
d
,"
"usedby=%
s
,using=%
s
,options=%
s
\r\n",
info
=
sdscat
fmt
(
info
,
"module:name=%
S
,ver=%
i
,api=%
i
,filters=%
i
,"
"usedby=%
S
,using=%
S
,options=%
S
\r\n
"
,
name
,
module
->
ver
,
module
->
apiver
,
(
int
)
listLength
(
module
->
filters
),
usedby
,
using
,
options
);
sdsfree
(
usedby
);
...
...
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