Minor: remove potential string copy from Column::from_qualified_name#10947
Merged
comphead merged 1 commit intoapache:mainfrom Jun 17, 2024
Merged
Minor: remove potential string copy from Column::from_qualified_name#10947comphead merged 1 commit intoapache:mainfrom
comphead merged 1 commit intoapache:mainfrom
Conversation
alamb
commented
Jun 17, 2024
| @@ -109,21 +109,21 @@ impl Column { | |||
| /// `foo.BAR` would be parsed to a reference to relation `foo`, column name `bar` (lower case) | |||
| /// where `"foo.BAR"` would be parsed to a reference to column named `foo.BAR` | |||
| pub fn from_qualified_name(flat_name: impl Into<String>) -> Self { | |||
Contributor
Author
There was a problem hiding this comment.
I think we could make this significantly better for the common case (non error) by changing the signature to take &str but that would be a breaking change, and I think we should only do it if benchmarking shows it helps.
Most of the time is actually taken parsing the identifier
1a6048d to
5d3ec72
Compare
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.
Which issue does this PR close?
Closes #.
Rationale for this change
While profiling code for for CSE copy removal (#10835) and noticed that 5% of the time was spent in
Column::from_qualified_name(see screen shot)When I looked into this a bit more, it seems to be copying the string twice on the error path which can be avoided.
I doubt this will matter much in practice but I also think the code is cleaner this way.
What changes are included in this PR?
Only make a string when needed
Are these changes tested?
Are there any user-facing changes?