-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Use HashMap::add in SVGTextLayoutAttributesBuilder #32358
base: main
Are you sure you want to change the base?
Use HashMap::add in SVGTextLayoutAttributesBuilder #32358
Conversation
https://bugs.webkit.org/show_bug.cgi?id=278292 rdar://134186468 Reviewed by NOBODY (OOPS!). Merge: https://chromium.googlesource.com/chromium/src.git/+/0f6c84977fee3a56a328e9baa1134b668a316569 Removes some redundancies and eliminates double-hashing. Do the update of default values last. * Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp: (WebCore::SVGTextLayoutAttributesBuilder::buildCharacterDataMap): (WebCore::SVGTextLayoutAttributesBuilder::fillCharacterDataMap):
EWS run on current version of this PR (hash 7afd778) |
} | ||
|
||
updateCharacterData(i, lastRotation, it->value, lengthContext, xListPtr, yListPtr, dxListPtr, dyListPtr, rotateListPtr); | ||
auto& data = m_characterDataMap.add((position.start + i + 1), SVGCharacterData()).iterator->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.
We should use HashMap::ensure()
to avoid creating a useless SVGCharacterData()
object when the key is already there.
} | ||
|
||
it->value.rotate = lastRotation; | ||
auto& data = m_characterDataMap.add((position.start + i + 1), SVGCharacterData()).iterator->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.
Ditto
// Fill character data map using child text positioning elements in top-down order. | ||
unsigned size = m_textPositions.size(); | ||
for (unsigned i = 0; i < size; ++i) | ||
fillCharacterDataMap(m_textPositions[i]); | ||
|
||
// Handle x/y default attributes. | ||
auto& data = m_characterDataMap.add((1), SVGCharacterData()).iterator->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.
Ditto
SVGCharacterData data; | ||
updateCharacterData(i, lastRotation, data, lengthContext, xListPtr, yListPtr, dxListPtr, dyListPtr, rotateListPtr); | ||
m_characterDataMap.set(position.start + i + 1, data); | ||
continue; |
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 logic has changed. You might want to check if isNewEntry
when using HashMap::add
and if so, continue to the next step of the loop.
SVGCharacterData data; | ||
data.rotate = lastRotation; | ||
m_characterDataMap.set(position.start + i + 1, data); | ||
continue; |
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.
ditto.
7afd778
7afd778