From dbf56b1d94910f04823e53e39ace1e5145bddc04 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 27 Oct 2010 17:06:12 -0400 Subject: [PATCH] More lig-id cleanup --- src/hb-buffer-private.hh | 4 ++-- src/hb-buffer.cc | 2 +- src/hb-ot-layout-gsub-private.hh | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index 2ad8212..ce95679 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -120,11 +120,11 @@ struct _hb_buffer_t { /* Other stuff */ - unsigned int max_lig_id; + unsigned int serial; /* Methods */ - inline unsigned int allocate_lig_id (void) { return max_lig_id++; } + inline unsigned int next_serial (void) { return serial++; } inline void swap (void) { _hb_buffer_swap (this); } inline void clear_output (void) { _hb_buffer_clear_output (this); } inline void next_glyph (void) { _hb_buffer_next_glyph (this); } diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index a75b8e9..2461046 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -228,7 +228,7 @@ hb_buffer_clear (hb_buffer_t *buffer) buffer->out_len = 0; buffer->i = 0; buffer->out_info = buffer->info; - buffer->max_lig_id = 0; + buffer->serial = 0; } hb_bool_t diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh index 7e37d51..577b34b 100644 --- a/src/hb-ot-layout-gsub-private.hh +++ b/src/hb-ot-layout-gsub-private.hh @@ -391,7 +391,7 @@ struct Ligature : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE); /* Allocate new ligature id */ - unsigned int lig_id = c->buffer->allocate_lig_id (); + unsigned int lig_id = allocate_lig_id (c->buffer); c->buffer->info[c->buffer->i].component() = 0; c->buffer->info[c->buffer->i].lig_id() = lig_id; @@ -427,6 +427,12 @@ struct Ligature return true; } + inline uint16_t allocate_lig_id (hb_buffer_t *buffer) const { + uint16_t lig_id = buffer->next_serial (); + if (unlikely (!lig_id)) lig_id = buffer->next_serial (); /* in case of overflows */ + return lig_id; + } + public: inline bool sanitize (hb_sanitize_context_t *c) { TRACE_SANITIZE (); -- 2.7.4