Remove a linear search in SkPictureRecord::addTextBlob.
It doesn't seem that harmful to have repeated text blobs in the array
if they occur within the same picture recording. And that does not seem
to be a common occurrence right now anyhow.
BUG=skia:2919
R=fmalita@chromium.org, reed@google.com, mtklein@google.com
Author: jbroman@chromium.org
Review URL: https://codereview.chromium.org/550043003
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index a6b6f61..b171691 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -1544,12 +1544,9 @@
}
void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
- int index = fTextBlobRefs.find(blob);
- if (index < 0) { // not found
- index = fTextBlobRefs.count();
- *fTextBlobRefs.append() = blob;
- blob->ref();
- }
+ int index = fTextBlobRefs.count();
+ *fTextBlobRefs.append() = blob;
+ blob->ref();
// follow the convention of recording a 1-based index
this->addInt(index + 1);
}