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

Remove trivial methods from the codebase #8498

Closed

Conversation

georgthegreat
Copy link
Contributor

This simplifies the code in GetUtf8CheckMode dramatically.

This is part 2 / x in #8494 fix.

@google-cla google-cla bot added the cla: yes label Apr 15, 2021
@@ -1011,29 +1011,16 @@ bool IsWellKnownMessage(const FileDescriptor* file) {
return well_known_files.find(file->name()) != well_known_files.end();
}

static bool FieldEnforceUtf8(const FieldDescriptor* field,
Copy link
Member

Choose a reason for hiding this comment

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

Sorry but unfortunately we need to keep these functions around. Within our internal version of the codebase we have some additional code in these functions for legacy reasons, to allow the UTF-8 enforcement to be disabled for particular fields. Even though the functions look pointless, it helps us to have them around so that we can easily apply our internal changes.

If you just want to fix an unused-parameter warning, it would be fine to remove the parameter names (i.e. just make it (const FieldDescriptor*, const Options&)) or add lines like (void) field;.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not working on unused parameter in protoc itself, but rather in the generated code.

It is ok if these methods would not be removed, though this will make interfaces a bit clumsier.

Could you, please, take a look on the question below?

@georgthegreat
Copy link
Contributor Author

@acozzette, @haberman could you, please, take a look onto GetOptimizeFor implelementation in cpp_helpers.cc?

Internally it invokes HasBootstrapProblem() which looks like a workaround for #4293, which was fixed by constinit introduction in 3.15. Could you confirm my speculations? If HasBootstrapProblem() could be removed, interface of GetUtf8CheckMode() could be simplified.

The method was introduced during sync from Google's internal codebase in b99994d, so there may be additional details available internally.

@acozzette
Copy link
Member

I believe the calls to HasBootstrapProblem() in GetOptimizeFor() were added a while ago when we were looking into the possibility of using CODE_SIZE for (almost) all protos in the build. That turned up some weird edge cases where it did not work, and we try to detect those with the HasBootstrapProblem() helper function so that we can fall back on the standard SPEED mode. I could be wrong but I don't think that logic was intended as a workaround for #4293.

@georgthegreat
Copy link
Contributor Author

Ok, thanks for the clarification.

I am closing thing PR due to the reasoning from above,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants