mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-29 09:34:05 +01:00
[svg] Use SortedArrayOf.bsearch
This commit is contained in:
1 parent
18dd6363a5
commit
9c1460e568
1 file changed
+3
-15
@@ -43,13 +43,6 @@ struct SVGDocumentIndexEntry
|
||||
inline int cmp (hb_codepoint_t g) const
|
||||
{ return g < startGlyphID ? -1 : g > endGlyphID ? 1 : 0; }
|
||||
|
||||
static int cmp (const void *pa, const void *pb)
|
||||
{
|
||||
const hb_codepoint_t *a = (const hb_codepoint_t *) pa;
|
||||
const SVGDocumentIndexEntry *b = (const SVGDocumentIndexEntry *) pb;
|
||||
return b->cmp (*a);
|
||||
}
|
||||
|
||||
inline hb_blob_t *reference_blob (hb_blob_t *svg_blob, unsigned int index_offset) const
|
||||
{
|
||||
if (svgDocLength == 0) return hb_blob_get_empty ();
|
||||
@@ -113,13 +106,8 @@ struct SVG
|
||||
|
||||
inline const SVGDocumentIndexEntry &get_glyph_entry (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
const SVGDocumentIndexEntry *rec = (SVGDocumentIndexEntry *)
|
||||
bsearch (&glyph_id,
|
||||
&(this+svgDocEntries).arrayZ,
|
||||
(this+svgDocEntries).len,
|
||||
sizeof (SVGDocumentIndexEntry),
|
||||
SVGDocumentIndexEntry::cmp);
|
||||
return likely (rec) ? *rec : Null(SVGDocumentIndexEntry);
|
||||
const SortedArrayOf<SVGDocumentIndexEntry> docs = this+svgDocEntries;
|
||||
return docs[docs.bsearch (glyph_id)];
|
||||
}
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||
@@ -131,7 +119,7 @@ struct SVG
|
||||
|
||||
protected:
|
||||
HBUINT16 version; /* Table version (starting at 0). */
|
||||
LOffsetTo<ArrayOf<SVGDocumentIndexEntry> >
|
||||
LOffsetTo<SortedArrayOf<SVGDocumentIndexEntry> >
|
||||
svgDocEntries; /* Offset (relative to the start of the SVG table) to the
|
||||
* SVG Documents Index. Must be non-zero. */
|
||||
/* Array of SVG Document Index Entries. */
|
||||
|
||||
Reference in new issue
Block a user