Skip to content

avoid path clone when not needed - #398

Merged
gkorland merged 6 commits into
masterfrom
avoid_path_clone
Jul 5, 2021
Merged

gkorland merged 6 commits into
masterfrom
avoid_path_clone

Conversation

@gkorland

@gkorland gkorland commented Jun 20, 2021 •

Copy link
Copy Markdown
Contributor

This should reduce the useless clone of the path when there is no need for backward compatibility with RedisJSON 1.0.x

oshadmi
oshadmi previously approved these changes Jun 20, 2021

@oshadmi oshadmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM👍🏼

Comment thread src/redisjson.rs
pub path: String,
pub fixed: String,
original_path: String,
fixed_path: Option<String>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just a thought,
Can we even consider (also later) avoiding the fixed_path member and calculate it when calling get_path which will return the moved String? (either original or fixed if needed)
(assuming that once we pass it to JSONPath selector we don't need it anymore)
This will shorten the lifetime of the cloned/mutated strings to the minimum, but it will probably have none to very small impact (unless paths: &mut Vec<Path> vector in method to_json is big)

@oshadmi oshadmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍🏼 LGTM

@gkorland
gkorland merged commit f001ee1 into master Jul 5, 2021
@gkorland
gkorland deleted the avoid_path_clone branch July 5, 2021 18:13
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.

4 participants