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

Unified Diff: third_party/harfbuzz-ng/src/hb-open-type-private.hh

Issue 16053004: Update harfbuzz-ng to 0.9.17 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 | « third_party/harfbuzz-ng/src/hb-graphite2.cc ('k') | third_party/harfbuzz-ng/src/hb-ot-layout.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/harfbuzz-ng/src/hb-open-type-private.hh
===================================================================
--- third_party/harfbuzz-ng/src/hb-open-type-private.hh (리비전 201894)
+++ third_party/harfbuzz-ng/src/hb-open-type-private.hh (작업 사본)
@@ -949,21 +949,22 @@
struct SortedArrayOf : ArrayOf<Type> {
template <typename SearchType>
- inline int search (const SearchType &x) const {
- unsigned int count = this->len;
- /* Linear search is *much* faster for small counts. */
- if (likely (count < 32)) {
- for (unsigned int i = 0; i < count; i++)
- if (this->array[i].cmp (x) == 0)
- return i;
- return -1;
- } else {
- struct Cmp {
- static int cmp (const SearchType *a, const Type *b) { return b->cmp (*a); }
- };
- const Type *p = (const Type *) bsearch (&x, this->array, this->len, sizeof (this->array[0]), (hb_compare_func_t) Cmp::cmp);
- return p ? p - this->array : -1;
+ inline int search (const SearchType &x) const
+ {
+ /* Hand-coded bsearch here since this is in the hot inner loop. */
+ int min = 0, max = (int) this->len - 1;
+ while (min <= max)
+ {
+ int mid = (min + max) / 2;
+ int c = this->array[mid].cmp (x);
+ if (c < 0)
+ max = mid - 1;
+ else if (c > 0)
+ min = mid + 1;
+ else
+ return mid;
}
+ return -1;
}
};
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-graphite2.cc ('k') | third_party/harfbuzz-ng/src/hb-ot-layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698