Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: Source/core/rendering/RenderGrid.cpp

Issue 28823002: [CSS Grid Layout] Do log(n) search in the named line vectors when positioning named line spans (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderGrid.cpp
diff --git a/Source/core/rendering/RenderGrid.cpp b/Source/core/rendering/RenderGrid.cpp
index d4c35e163ae01813baf517e6405cc215a7a856cc..85f9f05bb05419d0421b6447e248391abca026f9 100644
--- a/Source/core/rendering/RenderGrid.cpp
+++ b/Source/core/rendering/RenderGrid.cpp
@@ -1076,9 +1076,10 @@ PassOwnPtr<GridSpan> RenderGrid::resolveBeforeStartNamedGridLinePositionAgainstO
{
// The grid line inequality needs to be strict (which doesn't match the after / end case) because |resolvedOppositePosition|
// is already converted to an index in our grid representation (ie one was removed from the grid line to account for the side).
- // FIXME: This could be a binary search as |gridLines| is ordered.
- int firstLineBeforeOppositePositionIndex = gridLines.size() - 1;
- for (; firstLineBeforeOppositePositionIndex >= 0 && gridLines[firstLineBeforeOppositePositionIndex] > resolvedOppositePosition; --firstLineBeforeOppositePositionIndex) { }
+ size_t firstLineBeforeOppositePositionIndex = 0;
+ const size_t* firstLineBeforeOppositePosition = std::lower_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition);
+ if (firstLineBeforeOppositePosition != gridLines.end())
+ firstLineBeforeOppositePositionIndex = firstLineBeforeOppositePosition - gridLines.begin();
size_t gridLineIndex = std::max<int>(0, firstLineBeforeOppositePositionIndex - position.spanPosition() + 1);
size_t resolvedGridLinePosition = gridLines[gridLineIndex];
@@ -1089,9 +1090,10 @@ PassOwnPtr<GridSpan> RenderGrid::resolveBeforeStartNamedGridLinePositionAgainstO
PassOwnPtr<GridSpan> RenderGrid::resolveAfterEndNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines) const
{
- // FIXME: This could be a binary search as |gridLines| is ordered.
- size_t firstLineAfterOppositePositionIndex = 0;
- for (; firstLineAfterOppositePositionIndex < gridLines.size() && gridLines[firstLineAfterOppositePositionIndex] <= resolvedOppositePosition; ++firstLineAfterOppositePositionIndex) { }
+ size_t firstLineAfterOppositePositionIndex = gridLines.size() - 1;
+ const size_t* firstLineAfterOppositePosition = std::upper_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition);
+ if (firstLineAfterOppositePosition != gridLines.end())
+ firstLineAfterOppositePositionIndex = firstLineAfterOppositePosition - gridLines.begin();
size_t gridLineIndex = std::min(gridLines.size() - 1, firstLineAfterOppositePositionIndex + position.spanPosition() - 1);
size_t resolvedGridLinePosition = adjustGridPositionForAfterEndSide(gridLines[gridLineIndex]);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698