refactor(bvar): expand metric constructor macro#3400
Open
darion-yaphet wants to merge 1 commit into
Open
Conversation
Inline default/name/prefix constructors in Adder, Maxer, Miner, and IntRecorder, and drop the shared macro from variable.h. Co-authored-by: Cursor <[email protected]>
chenBright
reviewed
Jul 22, 2026
chenBright
left a comment
Contributor
There was a problem hiding this comment.
I think this is to simplify the code, which is fine, like the DISALLOW_COPY_AND_ASSIGN macro.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
COMMON_VARIABLE_CONSTRUCTORmacroAdder,Maxer,Miner, andIntRecorderwith explicit constructorsexpose(name), andexpose_as(prefix, name)Motivation
COMMON_VARIABLE_CONSTRUCTORhid public constructors behind macro expansion, making the code harder to read, search, and navigate with regular C++ tooling.This change keeps the API behavior unchanged while making the constructors visible at their declaration sites.
using Base::Basewas intentionally avoided because it would expose additional internal base constructors in the Babylon counter path and could broaden the publicAPI.
Testing
cmake --build build --target brpc-static -j6git diff --checkrg COMMON_VARIABLE_CONSTRUCTOR . -g '!build/**'Notes
The
WITH_BABYLON_COUNTERpath was not compiled locally because the available Bazel setup is missing the repository-required Bazel7.2.1binary.