Use sum instead of individual counts for channels/patterns (#119)

This commit is contained in:
Ali-Akber Saifee 2022-06-07 19:26:02 -07:00 committed by GitHub
parent 02bc4425ae
commit 746c04fb9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -38,7 +38,7 @@ void ConnectionContext::ChangeSubscription(bool to_add, bool to_reply, CmdArgLis
}
if (to_reply)
result[i] = conn_state.subscribe_info->channels.size();
result[i] = conn_state.subscribe_info->SubscriptionCount();
if (res) {
ShardId sid = Shard(channel, shard_set->size());
@ -132,7 +132,7 @@ void ConnectionContext::ChangePSub(bool to_add, bool to_reply, CmdArgList args)
}
if (to_reply)
result[i] = conn_state.subscribe_info->patterns.size();
result[i] = conn_state.subscribe_info->SubscriptionCount();
if (res) {
patterns.emplace_back(pattern);

View File

@ -58,6 +58,10 @@ struct ConnectionState {
return channels.empty() && patterns.empty();
}
unsigned SubscriptionCount() const {
return channels.size() + patterns.size();
}
SubscribeInfo() : borrow_token(0) {
}
};