Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a singleton for ShortNumberInfo in PhoneExtractor::RunFocusedArena #3297

Closed
wants to merge 3 commits into from

Conversation

svasudevan91
Copy link

This change is expected to reduce CPU usage by only initializing ShortNumberInfo once throughout the lifetime of the application. This pattern is already used in PhoneNumberUtil.

@svasudevan91 svasudevan91 requested a review from a team as a code owner November 10, 2023 05:38
Copy link

google-cla bot commented Nov 10, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Contributor

@katbohm katbohm left a comment

Choose a reason for hiding this comment

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

Hi there! Thank you for your pull request. My main note here is that by removing the public constructor and replacing it by getInstance() the public API is changed. Since LibPhoneNumber is a widely used library we shouldn't just remove an existing API.

ShortNumberInfoTest() : short_info_() {
PhoneNumberUtil::GetInstance()->SetLogger(new StdoutLogger());
ShortNumberInfoTest() : short_info_(ShortNumberInfo::GetInstance()) {
PhoneNumberUtil::GetInstance()->SetLogger(new StdoutLogger());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the space should stay.

@@ -44,9 +44,6 @@ class PhoneNumberUtil;

class ShortNumberInfo {
public:
ShortNumberInfo();
~ShortNumberInfo();
Copy link
Contributor

Choose a reason for hiding this comment

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

By removing these public constructor & destructor, the public API is changing. I don't think we can do that since the library is widely used.

@tvislavski tvislavski closed this Oct 3, 2024
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.

3 participants