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

Add strings.remove{pre,suf}fix methods #395

Merged
merged 2 commits into from
Feb 23, 2022
Merged

Conversation

adonovan
Copy link
Collaborator

See bazelbuild/starlark#212 for spec change

See bazelbuild/bazel#14824 for Java PR
See facebook/starlark-rust@7a7ef4b for Rust commit

Updates bazelbuild/starlark#185

Copy link
Contributor

@laurentlb laurentlb left a comment

Choose a reason for hiding this comment

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

lgtm

if err := UnpackPositionalArgs(b.Name(), args, kwargs, 1, &fix); err != nil {
return nil, err
}
if b.name[6] == 'p' {
Copy link
Contributor

Choose a reason for hiding this comment

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

As the function is short, it might be worth duplicating it instead of using b.name magic.

If you want to keep it like this, add a comment on the line

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since it's easy to avoid the duplication of source and object code (240 insns -> 160), and the cost of the extra load and two cjmps is trivial overall, I'd prefer to keep it this way.

But you're right it could be clearer. Commented in the form of self-documenting code:

	if b.name[len("remove")] == 'p' {

@adonovan
Copy link
Collaborator Author

@brandjon, can you approve? I assume @laurentlb did not because he no longer has the write bit.

@laurentlb
Copy link
Contributor

I don't think I've ever had write access in this repo.

@tetromino tetromino self-requested a review February 23, 2022 23:27
@adonovan adonovan merged commit 243c749 into master Feb 23, 2022
@adonovan adonovan deleted the strings.removeprefix branch October 28, 2022 18:31
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