chore(stats): improve get_line_charts for ReadService#1037
Open
yjhmelody wants to merge 1 commit intoblockscout:mainfrom
Open
chore(stats): improve get_line_charts for ReadService#1037yjhmelody wants to merge 1 commit intoblockscout:mainfrom
get_line_charts for ReadService#1037yjhmelody wants to merge 1 commit intoblockscout:mainfrom
Conversation
bragov4ik
requested changes
Aug 29, 2024
| fn add_chart_info_to_layout( | ||
| layout: Vec<types::LineChartCategory>, | ||
| chart_info: BTreeMap<String, EnabledChartEntry>, | ||
| layout: &[types::LineChartCategory], |
Contributor
There was a problem hiding this comment.
I agree with chart_info, but I think it should be cheaper to perform 1 big clone instead of multiple small (equivalent) clones for layout
Contributor
Author
There was a problem hiding this comment.
they are in heap,so i think its no difference,but only parts of fields need to be cloned,so i think it will be cheaper
Contributor
There was a problem hiding this comment.
Ok, probably there's no difference because of strings.
However, intersect_info effectively clones whole LineChartCategory, so I don't see a reason to use reference where move semantics fits ideally. I think it's a good practice to leave decision to clone or not for the caller.
Contributor
There was a problem hiding this comment.
I.e.
id- cloned directlytitle- cloned directlycharts_order-.iter()thencloneon each element
get_line_charts for ReadServiceget_line_charts for ReadService
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.
Reduce some clone for the function.