[buffer] Remove wrong optimization

While the cluster fields of the glyph string are usually sorted, they
wouldn't be in special cases (for example for non-native direction).
Blindly using bsearch is plain wrong.  If we want to reintroduce this
optimization we have to make sure we know the buffer clusters are
monotonic and in which direction.  Not sure it's worth it though.
This commit is contained in:
Behdad Esfahbod 2011-05-05 16:09:45 -04:00
parent 46df682851
commit 3935af1c0d
1 changed files with 3 additions and 13 deletions

View File

@ -470,20 +470,10 @@ _hb_buffer_set_masks (hb_buffer_t *buffer,
return;
}
/* XXX can't bsearch since .cluster may not be sorted. */
/* Binary search to find the start position and go from there. */
unsigned int min = 0, max = buffer->len;
while (min < max)
{
unsigned int mid = min + ((max - min) / 2);
if (buffer->info[mid].cluster < cluster_start)
min = mid + 1;
else
max = mid;
}
unsigned int count = buffer->len;
for (unsigned int i = min; i < count && buffer->info[i].cluster < cluster_end; i++)
buffer->info[i].mask = (buffer->info[i].mask & not_mask) | value;
for (unsigned int i = 0; i < count; i++)
if (cluster_start <= buffer->info[i].cluster && buffer->info[i].cluster < cluster_end)
buffer->info[i].mask = (buffer->info[i].mask & not_mask) | value;
}