Commit Graph

129 Commits

Author SHA1 Message Date
Behdad Esfahbod ef2a8f722f [VarComposite] Adjust for RESET_UNSPECIFIED_AXES semantic change
https://github.com/harfbuzz/boring-expansion-spec/issues/81
2023-02-06 12:04:16 -07:00
Behdad Esfahbod a24d4e9261 [array] Oops. Fix memcpy copy()! 2022-12-02 12:01:35 -07:00
Behdad Esfahbod 5e41766bb9 [array] Fix hb_bytes_t memcpy copy
Wasn't being used!
2022-12-02 12:01:35 -07:00
Behdad Esfahbod 3b68c7146f [array] Don't clear serializer buffer when copying out
Not needed.
2022-12-01 14:19:27 -07:00
Behdad Esfahbod d8d0e06694 [array] Comment 2022-11-29 21:35:54 -07:00
Behdad Esfahbod 3131aecf9f [array/hash] Fix asan issue
../src/hb-algs.hh:240:43: runtime error: reference binding to misaligned address 0x7ffe91a08b0e for type 'const unsigned int', which requires 4 byte alignment
2022-11-28 14:12:55 -07:00
Behdad Esfahbod 9d18180c3c [array] Use hb_hash instead of handrolling 2022-11-26 15:38:21 -07:00
Behdad Esfahbod e333223f26 [array] Optimize serializing copy() 2022-11-25 14:26:02 -07:00
Behdad Esfahbod dce3502e10 [array] Add commented-out static asserts
They don't work.
2022-11-23 18:34:54 -07:00
Behdad Esfahbod ae578705c2 [array] Write hash as range for loop again
Now that our range loop is faster than our own iter.
2022-11-22 12:23:17 -07:00
Behdad Esfahbod bca569ae53 [array] Speed up hash() for byte arrays 2022-11-21 23:19:42 -07:00
Behdad Esfahbod d7b492e3f5 Revert "[array] Remove hash specializations for bytes"
This reverts commit 213117317c.
2022-11-21 23:08:51 -07:00
Behdad Esfahbod b00a911fa7 [sorted-array] Add faster iterator implementation here as well 2022-11-21 12:11:30 -07:00
Behdad Esfahbod e82a3c69dd [array/vector] Optimize range-based for-loop
Avoid bounds-checking.
2022-11-21 12:00:10 -07:00
Behdad Esfahbod 921f45f46d [array] Rewrite hash() as dagger 2022-11-18 17:26:58 -07:00
Behdad Esfahbod 213117317c [array] Remove hash specializations for bytes
Not needed.
2022-11-18 17:24:44 -07:00
Behdad Esfahbod c7d57dcf26 [vector/array] Simplify qsort() 2022-11-16 21:21:31 -07:00
Behdad Esfahbod a87843be3d [array] Another try at sizeof sorted_array 2022-11-14 13:43:58 -07:00
Behdad Esfahbod df040de9b4 [array] Add a std::forward 2022-08-18 16:15:00 -06:00
Behdad Esfahbod c606978ee0 [array] Remove unused type pack 2022-08-18 16:13:56 -06:00
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