Skip to content

Conversation

@romange
Copy link
Collaborator

@romange romange commented Dec 12, 2025

No description provided.

@romange romange requested review from Copilot and dranikpg and removed request for Copilot December 12, 2025 03:11
Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted. Please double-check that the public command registration entry points remain defined after this refactor.

Comment augment review to trigger a new review at any time.

Copilot AI review requested due to automatic review settings December 12, 2025 03:15
@romange
Copy link
Collaborator Author

romange commented Dec 12, 2025

augment review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes redundant private function declarations from header files for ZSetFamily and StringFamily, and converts command handler static member functions to free functions prefixed with Cmd. The refactoring reduces boilerplate by eliminating the need to declare private command handlers in the header files while maintaining the same functionality through the HFUNC macro expansion pattern.

Key changes:

  • Removed private function declarations for command handlers from zset_family.h and string_family.h
  • Converted command handler static member functions from ZSetFamily::CommandName to free functions CmdCommandName in zset_family.cc
  • Converted command handler static member functions from StringFamily::CommandName to free functions CmdCommandName in string_family.cc
  • Updated HFUNC macros to use &Cmd##x pattern instead of &ZSetFamily::x or &StringFamily::x
  • Renamed internal helper function SetRange to SetRangeInternal to avoid naming conflict with the new CmdSetRange free function
  • Added explicit ZSetFamily:: qualifications for calls to public static methods that remain in the class

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/server/zset_family.h Removed 38 private command handler function declarations
src/server/zset_family.cc Converted command handlers to free functions (CmdZAdd, CmdZCard, etc.), updated HFUNC macro, added ZSetFamily:: qualifications for public static method calls
src/server/string_family.h Removed 25 private command handler function declarations
src/server/string_family.cc BUG: Register function incorrectly named as CmdRegister instead of StringFamily::Register; converted command handlers to free functions (CmdSet, CmdGet, etc.), updated HFUNC macro, renamed SetRange to SetRangeInternal

#define HFUNC(x) SetHandler(&StringFamily::x)
#define HFUNC(x) SetHandler(&Cmd##x)

void StringFamily::Register(CommandRegistry* registry) {
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name should be StringFamily::Register to match the declaration in the header file (string_family.h:20), not CmdRegister. This will cause a linker error because StringFamily::Register is declared but not defined, while CmdRegister is defined but never called. The function is invoked as StringFamily::Register(&registry_) in main_service.cc:3060.

Copilot uses AI. Check for mistakes.
Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Comment augment review to trigger a new review at any time.

}

void StringFamily::Set(CmdArgList args, const CommandContext& cmnd_cntx) {
void CmdSet(CmdArgList args, const CommandContext& cmnd_cntx) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Cmd* handlers are now free functions outside the existing anonymous namespace, so they get external linkage. Consider moving them into the anonymous namespace (or making them static) to avoid exporting many Cmd* symbols and potential ODR/link collisions (also applies to the other Cmd* handlers in this file).

🤖 Was this useful? React with 👍 or 👎

}

void ZSetFamily::BZPopMin(CmdArgList args, const CommandContext& cmd_cntx) {
void CmdBZPopMin(CmdArgList args, const CommandContext& cmd_cntx) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Cmd* command handlers are now file-scope free functions outside the anonymous namespace, so they get external linkage. Consider putting them in the anonymous namespace (or making them static) to prevent leaking lots of Cmd* symbols and reduce the risk of ODR/link collisions (also applies to the other Cmd* handlers in this file).

🤖 Was this useful? React with 👍 or 👎

@romange
Copy link
Collaborator Author

romange commented Dec 12, 2025

@dranikpg I removed from two families if you are positive with this code removal - I will proceed with others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants