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
5a3d8574
Commit
5a3d8574
authored
Apr 02, 2020
by
antirez
Browse files
LCS: output LCS len as well in IDX mode.
parent
3f96e162
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/t_string.c
View file @
5a3d8574
...
@@ -602,8 +602,11 @@ void lcsCommand(client *c) {
...
@@ -602,8 +602,11 @@ void lcsCommand(client *c) {
/* Start with a deferred array if we have to emit the ranges. */
/* Start with a deferred array if we have to emit the ranges. */
uint32_t
arraylen
=
0
;
/* Number of ranges emitted in the array. */
uint32_t
arraylen
=
0
;
/* Number of ranges emitted in the array. */
if
(
getidx
&&
idxkey
==
NULL
)
if
(
getidx
&&
idxkey
==
NULL
)
{
addReplyMapLen
(
c
,
2
);
addReplyBulkCString
(
c
,
"matches"
);
arraylenptr
=
addReplyDeferredLen
(
c
);
arraylenptr
=
addReplyDeferredLen
(
c
);
}
i
=
alen
,
j
=
blen
;
i
=
alen
,
j
=
blen
;
while
(
computelcs
&&
i
>
0
&&
j
>
0
)
{
while
(
computelcs
&&
i
>
0
&&
j
>
0
)
{
...
@@ -669,6 +672,8 @@ void lcsCommand(client *c) {
...
@@ -669,6 +672,8 @@ void lcsCommand(client *c) {
/* Reply depending on the given options. */
/* Reply depending on the given options. */
if
(
arraylenptr
)
{
if
(
arraylenptr
)
{
addReplyBulkCString
(
c
,
"len"
);
addReplyLongLong
(
c
,
LCS
(
alen
,
blen
));
setDeferredArrayLen
(
c
,
arraylenptr
,
arraylen
);
setDeferredArrayLen
(
c
,
arraylenptr
,
arraylen
);
}
else
if
(
getlen
)
{
}
else
if
(
getlen
)
{
addReplyLongLong
(
c
,
LCS
(
alen
,
blen
));
addReplyLongLong
(
c
,
LCS
(
alen
,
blen
));
...
...
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