mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 08:21:32 +01:00
[subset/cff1] Don't allocate memory for retaingid holes
40% speedup in BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/retaingids/10 benchmark.
This commit is contained in:
1 parent
b5792f117a
commit
054f966a57
4 files changed
+25
-4
No files matched your search
@@ -26,6 +26,8 @@
|
||||
#ifndef HB_CFF_INTERP_COMMON_HH
|
||||
#define HB_CFF_INTERP_COMMON_HH
|
||||
|
||||
extern HB_INTERNAL const unsigned char *endchar_str;
|
||||
|
||||
namespace CFF {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "hb-aat-layout-common.hh"
|
||||
#include "hb-aat-layout-feat-table.hh"
|
||||
#include "hb-cff-interp-common.hh"
|
||||
#include "hb-ot-layout-common.hh"
|
||||
#include "hb-ot-cmap-table.hh"
|
||||
#include "OT/Color/COLR/COLR.hh"
|
||||
@@ -58,6 +59,8 @@ DEFINE_NULL_NAMESPACE_BYTES (AAT, Lookup) = {0xFF,0xFF};
|
||||
/* hb_map_t */
|
||||
|
||||
const hb_codepoint_t minus_1 = -1;
|
||||
static const unsigned char static_endchar_str[] = {OpCode_endchar};
|
||||
const unsigned char *endchar_str = static_endchar_str;
|
||||
|
||||
/* hb_face_t */
|
||||
|
||||
|
||||
@@ -809,7 +809,12 @@ struct subr_subsetter_t
|
||||
|
||||
if (endchar_op != OpCode_Invalid)
|
||||
for (; last < gid; last++)
|
||||
buffArray.arrayZ[last].push (endchar_op);
|
||||
{
|
||||
// Hack to point vector to static string.
|
||||
auto &b = buffArray.arrayZ[last];
|
||||
b.length = 1;
|
||||
b.arrayZ = const_cast<unsigned char *>(endchar_str);
|
||||
}
|
||||
|
||||
last++; // Skip over gid
|
||||
unsigned int fd = acc.fdSelect->get_fd (old_glyph);
|
||||
@@ -820,7 +825,12 @@ struct subr_subsetter_t
|
||||
}
|
||||
if (endchar_op != OpCode_Invalid)
|
||||
for (; last < num_glyphs; last++)
|
||||
buffArray.arrayZ[last].push (endchar_op);
|
||||
{
|
||||
// Hack to point vector to static string.
|
||||
auto &b = buffArray.arrayZ[last];
|
||||
b.length = 1;
|
||||
b.arrayZ = const_cast<unsigned char *>(endchar_str);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+8
-2
@@ -102,8 +102,14 @@ struct hb_vector_t
|
||||
|
||||
void fini ()
|
||||
{
|
||||
shrink_vector (0);
|
||||
hb_free (arrayZ);
|
||||
/* We allow a hack to make the vector point to a foriegn array
|
||||
* by the user. In that case length/arrayZ are non-zero but
|
||||
* allocated is zero. Don't free anything. */
|
||||
if (!allocated)
|
||||
{
|
||||
shrink_vector (0);
|
||||
hb_free (arrayZ);
|
||||
}
|
||||
init ();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user