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

TextFit: Internal review #1

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

random3940
Copy link
Owner

Took the liberty to open this to have an easier way to discuss the changes.

@@ -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) {
Copy link
Owner Author

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?

if (value.HasMember(property)) {
auto& v = value[property];
if (v.IsString()) {
return parseTextFit(v.GetString());
Copy link
Owner Author

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_,
Copy link
Owner Author

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?

@qqz003 qqz003 force-pushed the support-textFit branch 2 times, most recently from 8241c81 to 1d27c79 Compare August 29, 2024 02:50
@qqz003 qqz003 deleted the support-textFit branch October 9, 2024 07:43
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