Index: src/core/SkConvolver.cpp |
=================================================================== |
--- src/core/SkConvolver.cpp (revision 13679) |
+++ src/core/SkConvolver.cpp (working copy) |
@@ -283,6 +283,7 @@ |
firstNonZero++; |
} |
+ int initialOffset = fFilterValues.count(); |
if (firstNonZero < filterLength) { |
// Here we have at least one non-zero factor. |
int lastNonZero = filterLength - 1; |
@@ -294,9 +295,13 @@ |
filterLength = lastNonZero + 1 - firstNonZero; |
SkASSERT(filterLength > 0); |
+ // Calling fFilterValues.reset(), or push_back() in a loop, are expensive. |
+ // Over-allocate so we can do it once instead of iteratively. |
+ if (!initialOffset) fFilterValues.resize_back(filterLength * filterLength); |
for (int i = firstNonZero; i <= lastNonZero; i++) { |
- fFilterValues.push_back(filterValues[i]); |
+ fFilterValues[initialOffset + i - firstNonZero] = filterValues[i]; |
} |
+ |
} else { |
// Here all the factors were zeroes. |
filterLength = 0; |