From 6fbb59aba6680225d13a6c3e0ba7d033096e6c55 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 18 Jun 2020 15:12:37 -0700 Subject: [PATCH] Use daggers in a few get_array functions As I review https://github.com/harfbuzz/harfbuzz/pull/2471 --- src/hb-ot-layout-common.hh | 21 +++++++++++---------- src/hb-ot-layout-gdef-table.hh | 7 +++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 132e9522b..37f1d23bd 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -347,11 +347,12 @@ struct RecordArrayOf : SortedArrayOf> unsigned int *record_count /* IN/OUT */, hb_tag_t *record_tags /* OUT */) const { - if (record_count) { - const Record *arr = this->sub_array (start_offset, record_count); - unsigned int count = *record_count; - for (unsigned int i = 0; i < count; i++) - record_tags[i] = arr[i].tag; + if (record_count) + { + + this->sub_array (start_offset, record_count) + | hb_map (&Record::tag) + | hb_sink (hb_array (record_tags, *record_count)) + ; } return this->len; } @@ -464,11 +465,11 @@ struct IndexArray : ArrayOf unsigned int *_count /* IN/OUT */, unsigned int *_indexes /* OUT */) const { - if (_count) { - const HBUINT16 *arr = this->sub_array (start_offset, _count); - unsigned int count = *_count; - for (unsigned int i = 0; i < count; i++) - _indexes[i] = arr[i]; + if (_count) + { + + this->sub_array (start_offset, _count) + | hb_sink (hb_array (_indexes, *_count)) + ; } return this->len; } diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh index e655e2089..e76ecf9a8 100644 --- a/src/hb-ot-layout-gdef-table.hh +++ b/src/hb-ot-layout-gdef-table.hh @@ -73,10 +73,9 @@ struct AttachList if (point_count) { - hb_array_t array = points.sub_array (start_offset, point_count); - unsigned int count = array.length; - for (unsigned int i = 0; i < count; i++) - point_array[i] = array[i]; + + points.sub_array (start_offset, point_count) + | hb_sink (hb_array (point_array, *point_count)) + ; } return points.len;