diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-07-25 10:48:52 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-07-25 10:48:52 +0000 |
commit | 120fbb4ff2102335d09b937b3b63a9eed6ab66bb (patch) | |
tree | 536783132e9340733acf05aa2086936b22066771 /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh | |
parent | 838bc80097f80371675cb700320a76c6a0ea6ab6 (diff) |
harfbuzz-2.7.0
git-svn-id: svn://tug.org/texlive/trunk@55937 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh index 172d9c13cc9..568cd02c791 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-array.hh @@ -129,20 +129,27 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&> template <typename T> Type *lsearch (const T &x, Type *not_found = nullptr) { - unsigned int count = length; - for (unsigned int i = 0; i < count; i++) - if (!this->arrayZ[i].cmp (x)) - return &this->arrayZ[i]; - return not_found; + unsigned i; + return lfind (x, &i) ? &this->arrayZ[i] : not_found; } template <typename T> const Type *lsearch (const T &x, const Type *not_found = nullptr) const { - unsigned int count = length; - for (unsigned int i = 0; i < count; i++) + unsigned i; + return lfind (x, &i) ? &this->arrayZ[i] : not_found; + } + template <typename T> + bool lfind (const T &x, unsigned *pos = nullptr) const + { + for (unsigned i = 0; i < length; ++i) if (!this->arrayZ[i].cmp (x)) - return &this->arrayZ[i]; - return not_found; + { + if (pos) + *pos = i; + return true; + } + + return false; } hb_sorted_array_t<Type> qsort (int (*cmp_)(const void*, const void*)) |