| Summary: | Minimize children vector capacity changes in PlatformCALayerRemote::recursiveBuildTransaction() | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Chris Dumez <cdumez> | ||||
| Component: | Layout and Rendering | Assignee: | Chris Dumez <cdumez> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | commit-queue, simon.fraser, thorton, zalan | ||||
| Priority: | P2 | ||||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
Chris Dumez
2015-07-30 10:21:41 PDT
Created attachment 257839 [details]
Patch
Comment on attachment 257839 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=257839&action=review Could we also reserveInitialCapacity()/uncheckedAppend()? > Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:162 > + for (size_t i = 0; i < m_children.size(); ++i) Why change this? Comment on attachment 257839 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=257839&action=review >> Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:162 >> + for (size_t i = 0; i < m_children.size(); ++i) > > Why change this? reserveInitialCapacity() would not be OK here as the m_properties.children is not a newly created Vector here (may have elements already). I guess we could do something like: m_properties.children.shrink(0); // clear items without freeing underlying capacity m_properties.children.reserve(reserveCapacity); // Resize underlying capacity for (const auto& layer : m_children) m_properties.children.uncheckedAppend(layer->layerID()); That said, I still prefer my approach as I find it clearer than shrink() + reserveCapacity(). Also, the pattern I used is not unusual (see for e.g. copy*ToVector() in HashMap.h. Comment on attachment 257839 [details] Patch Clearing flags on attachment: 257839 Committed r187594: <http://trac.webkit.org/changeset/187594> All reviewed patches have been landed. Closing bug. |