-
Notifications
You must be signed in to change notification settings - Fork 0
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
TextFit: Internal review #1
base: main
Are you sure you want to change the base?
Conversation
src/mbgl/sprite/sprite_parser.cpp
Outdated
@@ -150,6 +152,36 @@ std::optional<style::ImageContent> getContent(const JSValue& value, const char* | |||
return std::nullopt; | |||
} | |||
|
|||
std::optional<style::TextFit> parseTextFit(const std::string& value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this pattern used in other parts of ML/N for parsing values? Creating and filling static unordered_map, filling it with std::strings seems like overkill, especially given that there is only three constants to check against.
I'm interested to learn why this was chosen over simple string comparison?
src/mbgl/sprite/sprite_parser.cpp
Outdated
if (value.HasMember(property)) { | ||
auto& v = value[property]; | ||
if (v.IsString()) { | ||
return parseTextFit(v.GetString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would create std::string and copy underlying buffer. ML/N already uses std::string_view and I think it will be a good fit here.
const float boxScale, | ||
const float padding, | ||
const style::SymbolPlacementType placement, | ||
IndexedSubfeature indexedFeature_, | ||
const RefIndexedSubfeature& indexedFeature_, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this changed? "Ref" imposes some lifetime restrictions on index it's using - are those guaranteed to hold? Why TextFit changes this?
8241c81
to
1d27c79
Compare
9fb4964
to
566f9b6
Compare
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <[email protected]>
for more information, see https://pre-commit.ci
b8a362f
to
0874fe1
Compare
Took the liberty to open this to have an easier way to discuss the changes.