Commit Graph

109 Commits

Author SHA1 Message Date
Behdad Esfahbod b475a2ab29 [array] Adjust operator != 2022-07-17 18:44:11 -06:00
Behdad Esfahbod 4b3afafb00 [array] Use hb_swap() in reverse() 2022-07-13 15:13:07 -06:00
Behdad Esfahbod 97ea10a63a Remove old nullptr_t hacks
Were used for hashmap before.
2022-06-02 11:23:38 -06:00
Behdad Esfahbod 975a5f9194 [array] Use hb_memcmp instead of memcmp
Fixes ubsan error.
2022-05-20 12:34:49 -06:00
Behdad Esfahbod 4266cf3be2 [array] Specialize operator== for bytes_t and ubytes_t 2022-05-19 18:16:54 -06:00
Behdad Esfahbod 1c8226ed14 Fix compiler warning
On Mac compiler:

FAILED: src/libharfbuzz.0.dylib.p/hb-ot-tag.cc.o
c++ -Isrc/libharfbuzz.0.dylib.p -Isrc -I../src -I. -I.. -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/graphite2/1.3.14/include -I/usr/local/Cellar/glib/2.72.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.72.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.45/include -Xclang -fcolor-diagnostics --coverage -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++11 -fno-rtti -O2 -g -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -DHAVE_CONFIG_H -Wno-non-virtual-dtor -MD -MQ src/libharfbuzz.0.dylib.p/hb-ot-tag.cc.o -MF src/libharfbuzz.0.dylib.p/hb-ot-tag.cc.o.d -o src/libharfbuzz.0.dylib.p/hb-ot-tag.cc.o -c ../src/hb-ot-tag.cc
In file included from ../src/hb-ot-tag.cc:29:
In file included from ../src/hb.hh:481:
../src/hb-array.hh:359:14: error: missing default argument on parameter 'ds'
              Ts... ds) const
                    ^
../src/hb-ot-tag.cc:292:58: note: in instantiation of function template specialization 'hb_sorted_array_t<const LangTag>::bfind<const char *, unsigned int>' requested here
    if (hb_sorted_array (ot_languages, ot_languages_len).bfind (lang_str, &tag_idx,
                                                         ^
1 error generated.
2022-05-17 15:28:50 -06:00
Behdad Esfahbod c1f4b57c06 [ot-tags] Optimize language comparison
Now that we know both strings are of equal len of 2 or 3, optimize.

Part of https://github.com/harfbuzz/harfbuzz/issues/3591

Before:
------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       8.50 ns         8.47 ns     81221549
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         79.6 ns         79.3 ns      8785804
BM_hb_ot_tags_from_script_and_language/COMMON en_US         40.0 ns         39.9 ns     17462768
BM_hb_ot_tags_from_script_and_language/LATIN en_US          39.2 ns         39.1 ns     17886793
BM_hb_ot_tags_from_script_and_language/COMMON none          4.31 ns         4.30 ns    162805417
BM_hb_ot_tags_from_script_and_language/LATIN none           4.32 ns         4.31 ns    162656688

After:
------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       8.27 ns         8.24 ns     81868701
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         56.1 ns         56.0 ns     12353284
BM_hb_ot_tags_from_script_and_language/COMMON en_US         24.3 ns         24.2 ns     28955030
BM_hb_ot_tags_from_script_and_language/LATIN en_US          24.5 ns         24.4 ns     28664868
BM_hb_ot_tags_from_script_and_language/COMMON none          4.35 ns         4.34 ns    161190014
BM_hb_ot_tags_from_script_and_language/LATIN none           4.36 ns         4.34 ns    161319000
2022-05-17 15:19:40 -06:00
luz paz e2e305066a Fix various typos
Found via `codespell -q 3 -S ./perf/texts -L actualy,ba,beng,fo,gir,inout,nd,ot,pres,ro,te,teh,timne`
2022-01-16 05:39:03 -08:00
Behdad Esfahbod 325f26290e [array] Fix a couple constexpr warnings
./subprojects/harfbuzz/src/hb-array.hh:71:25: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
  constexpr hb_array_t& operator = (const hb_array_t<U> &o)
                        ^
                                                            const
../subprojects/harfbuzz/src/hb-array.hh:72:5: warning: use of this statement in a constexpr function is a C++14 extension [-Wc++14-extensions]
  { arrayZ = o.arrayZ; length = o.length; backwards_length = o.backwards_length; return *this; }
    ^
../subprojects/harfbuzz/src/hb-array.hh:329:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
  constexpr hb_sorted_array_t& operator = (const hb_array_t<U> &o)
                               ^
                                                                   const
../subprojects/harfbuzz/src/hb-array.hh:330:5: warning: use of this statement in a constexpr function is a C++14 extension [-Wc++14-extensions]
  { hb_array_t<Type> (*this) = o; return *this; }
    ^
4 warnings generated.
2021-11-19 17:19:09 -07:00
Behdad Esfahbod 4731b10736 [array] Mark constructors constexpr
../src/hb-map.hh:44:38: note: non-constexpr constructor 'hb_array_t' cannot be used in a constant expression
  static constexpr K INVALID_KEY   = kINVALID;
                                     ^
2021-11-19 12:33:37 -07:00
Behdad Esfahbod 1da7423ed9 [array] Add constructor taking std::nullptr_t
Not all impls implement nullptr_t in a way that would automatically
convert to what we were accepting.

In file included from ../src/test-map.cc:27:
../src/hb-map.hh:44:22: error: no viable conversion from 'nullptr_t' to 'const hb_array_t<const char>'
  static constexpr K INVALID_KEY   = kINVALID;
                     ^               ~~~~~~~~
2021-11-19 12:11:41 -07:00
Behdad Esfahbod cba17fd101 [array] Add default methods again, this time the full set
Should add tests.
2021-11-19 11:49:03 -07:00
Behdad Esfahbod 54e7d6267b [array] Remove defaulted destructor 2021-11-03 14:43:34 -06:00
Behdad Esfahbod d2c364f6e7 [array] Use default methods 2021-11-01 21:55:14 -06:00
Behdad Esfahbod 03cd9c5cba Align lfind() API to match bfind() 2021-07-22 11:38:27 -07:00
Behdad Esfahbod 2337f0d047 Internally use hb_malloc/.../hb_free instead of malloc/.../free
Redefining those stock names as macros was conflicting with gcc 10
headers.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3044
2021-07-08 10:54:09 -07:00
Behdad Esfahbod bb48bf52a4 Rename misc uses of "free"
In preparation for fixing https://github.com/harfbuzz/harfbuzz/issues/3044
2021-07-08 10:54:09 -07:00
Behdad Esfahbod 499248c533 [blob] Use min_size, instead of null_size in .as<T>()
Part of https://github.com/harfbuzz/harfbuzz/pull/2067
2021-04-16 13:14:48 -06:00
Behdad Esfahbod 836814a571 [array] Swap order of args to hb_equal()
Prioritizes Key::cmp() over table's cmp.
2021-02-09 18:48:05 -07:00
Behdad Esfahbod 921b4e46b0 [algs] Add hb_equal()
Use in hb_array_t::lfind()
2021-02-01 11:30:39 -08:00
Ebrahim Byagowi 08d57d9eca
Add hb_array_t::lfind 2020-06-28 13:13:25 +04:30
Garret Rieger 14a7b6f1ab Set hb_buffer_t to use array_t.reverse(). 2020-03-04 16:52:29 -08:00
Garret Rieger 50129b03a1 Add a reverse () call to hb_array_t. 2020-02-26 11:09:54 -08:00
Behdad Esfahbod fa7edf87c9 [bsearch] Massage API some more 2019-12-09 17:51:41 -06:00
Behdad Esfahbod 48eef2724c [algs/array] Consolidate the last two bsearch implementations!
Yay!  Seems to work.
2019-12-06 05:04:11 +00:00
Behdad Esfahbod fd6df520a1 [array] Isolate bsearch implementation more 2019-12-06 03:01:34 +00:00
Behdad Esfahbod 06d3c2019f [array] Simplify bfind() positioning
I had copied the old scheme from fontconfig's fccharset.c.  I just
convinced myself that this change is correct and produces exact
same results.  But I also am skeptical.  Anyone else feel like
convincing themselves as well please?
2019-12-06 02:52:54 +00:00
Ebrahim Byagowi d67ba649a3 Rename hb_array_t::in_range to hb_array_t::check_range 2019-12-06 02:27:23 +00:00
Ebrahim Byagowi 72d83a0280 Make hb_array_t::in_range similar to hb_sanitize_context_t::check_range 2019-12-06 02:27:23 +00:00
Ebrahim Byagowi 3958f6fb23 Add in_range in hb_bytes_t to merge range_checker_t with it 2019-10-29 23:16:05 +03:30
Garret Rieger 05bcdb39d8 Add a specialization of array_t:hash for hb_bytes_t and hb_ubytes_t. 2019-10-22 13:33:50 -07:00
Garret Rieger eab191fd9c Rewrite hash and == function for hb_array_t as a plain loop.
Profling showed that the current implementation were accounting for nearly all processing time in some cases. These implementations look to be about 10x faster.
2019-10-18 15:10:30 -07:00
Ebrahim Byagowi 0558413f27 Minor, tweak spaces 2019-10-01 13:50:11 +03:30
Behdad Esfahbod 7eafe94705 Revert "[array] Add chop()"
This reverts commit 545fe9d9f0.

Breaks gcc 4.8 and MSVC all versions.

Will add hb_chop() that works on all iterators instead.
2019-08-31 12:24:56 -05:00
Behdad Esfahbod 545fe9d9f0 [array] Add chop()
Takes n, and returns iterator of iterators that contain up to
n items each.  Basically cuts the array into subarrays of size n.
The last sub-array might contain fewer.

Ideally this should become a generic iter tool, not array-specific,
so we can use it in GPOS to chop a value matrix into rows and elements.
2019-08-29 15:48:21 -07:00
Behdad Esfahbod c72589f13f [iter] Change item_size to get_item_size()
By moving access to hb_static_size(Type) into a function instead of
a class-const, we can refer to iter types of incomplete types, which
come handy when a method of hb_array_t wants to return iterator
of hb_array_t.  That kind of stuff.   Next commit needs this to
build on clang...
2019-08-29 15:45:21 -07:00
Behdad Esfahbod d58e248df6 [array] Add truncate() method 2019-08-29 15:23:48 -07:00
Behdad Esfahbod a06edf1430 [array] Use injected class name more 2019-08-29 15:21:18 -07:00
Ebrahim Byagowi dce42cef2b [glyf] Move GlyphHeader::from_bytes to hb_bytes_t, introduce .as<T> () 2019-08-27 17:38:09 +04:30
Ebrahim Byagowi a0b4ac4dce Turn 8 spaces to tab across the project
According to the current code style of the project
2019-08-27 02:40:41 +04:30
Ebrahim Byagowi eff579f743 Update and use internal qsort everywhere 2019-06-08 12:53:27 -07:00
Behdad Esfahbod d822e0a16f [array] Adjust operator!=
See comments.
2019-05-15 16:30:08 -07:00
Behdad Esfahbod d0df996cdc Use implicit lambda return type 2019-05-15 00:32:41 -07:00
Behdad Esfahbod 889dc1eb06 [iter] Remove sort categorization
See comments.
2019-05-14 22:28:07 -07:00
Behdad Esfahbod 513762849a [iter] Track strictly-sorted iterators
This make output of hb_enumerate() sorted regardless of input iterator.
2019-05-13 15:36:14 -07:00
David Corbett b854d4ff46 [array] Fix rewinding 2019-05-11 11:52:40 -07:00
Behdad Esfahbod 322627ae1d Whitespace 2019-05-09 16:08:10 -07:00
Behdad Esfahbod 726002a6a6 [iter] Make hb_is_iterator_of() check is_convertible
Instead of is_cr_convertible.
2019-05-09 15:24:25 -07:00
Behdad Esfahbod 3476445420 Remove unnecessary template keyword
Should fix MSVC.
2019-05-08 21:14:01 -07:00
Behdad Esfahbod e8b45c1933 [array] Add .copy() 2019-05-08 16:37:38 -07:00