From 441cca235477a5399af214c9ac85320d4de69f0b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 23 Apr 2019 23:49:21 -0400 Subject: [PATCH] Use hb_forward() when forwarding parameter pack --- src/hb-open-type.hh | 32 ++++++++++++++++---------------- src/hb-serialize.hh | 3 ++- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index f4e7cd6d0..d165f475f 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -285,7 +285,7 @@ struct OffsetTo : Offset } template - bool serialize_subset (hb_subset_context_t *c, const T &src, const void *base, Ts ...ds) + bool serialize_subset (hb_subset_context_t *c, const T &src, const void *base, Ts &&...ds) { *this = 0; if (has_null && &src == &Null (T)) @@ -295,7 +295,7 @@ struct OffsetTo : Offset s->push (); - bool ret = src.subset (c, ds...); + bool ret = src.subset (c, hb_forward (ds)...); if (ret || !has_null) s->add_link (*this, s->pop_pack (), base); @@ -315,12 +315,12 @@ struct OffsetTo : Offset } template - bool sanitize (hb_sanitize_context_t *c, const void *base, Ts ...ds) const + bool sanitize (hb_sanitize_context_t *c, const void *base, Ts &&...ds) const { TRACE_SANITIZE (this); return_trace (sanitize_shallow (c, base) && (this->is_null () || - StructAtOffset (base, *this).sanitize (c, ds...) || + StructAtOffset (base, *this).sanitize (c, hb_forward (ds)...) || neuter (c))); } @@ -418,12 +418,12 @@ struct UnsizedArrayOf return_trace (true); } template - bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base, Ts ...ds) const + bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base, Ts &&...ds) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c, count))) return_trace (false); for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base, ds...))) + if (unlikely (!arrayZ[i].sanitize (c, base, hb_forward (ds)...))) return_trace (false); return_trace (true); } @@ -464,11 +464,11 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf } template - bool sanitize (hb_sanitize_context_t *c, unsigned int count, Ts ...ds) const + bool sanitize (hb_sanitize_context_t *c, unsigned int count, Ts &&...ds) const { TRACE_SANITIZE (this); return_trace ((UnsizedOffsetArrayOf - ::sanitize (c, count, this, ds...))); + ::sanitize (c, count, this, hb_forward (ds)...))); } }; @@ -589,13 +589,13 @@ struct ArrayOf return_trace (true); } template - bool sanitize (hb_sanitize_context_t *c, const void *base, Ts ...ds) const + bool sanitize (hb_sanitize_context_t *c, const void *base, Ts &&...ds) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); unsigned int count = len; for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base, ds...))) + if (unlikely (!arrayZ[i].sanitize (c, base, hb_forward (ds)...))) return_trace (false); return_trace (true); } @@ -663,10 +663,10 @@ struct OffsetListOf : OffsetArrayOf } template - bool sanitize (hb_sanitize_context_t *c, Ts ...ds) const + bool sanitize (hb_sanitize_context_t *c, Ts &&...ds) const { TRACE_SANITIZE (this); - return_trace (OffsetArrayOf::sanitize (c, this, ds...)); + return_trace (OffsetArrayOf::sanitize (c, this, hb_forward (ds)...)); } }; @@ -765,13 +765,13 @@ struct ArrayOfM1 { return lenM1.static_size + (lenM1 + 1) * Type::static_size; } template - bool sanitize (hb_sanitize_context_t *c, const void *base, Ts ...ds) const + bool sanitize (hb_sanitize_context_t *c, const void *base, Ts &&...ds) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); unsigned int count = lenM1 + 1; for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base, ds...))) + if (unlikely (!arrayZ[i].sanitize (c, base, hb_forward (ds)...))) return_trace (false); return_trace (true); } @@ -970,13 +970,13 @@ struct VarSizedBinSearchArrayOf return_trace (true); } template - bool sanitize (hb_sanitize_context_t *c, const void *base, Ts ...ds) const + bool sanitize (hb_sanitize_context_t *c, const void *base, Ts &&...ds) const { TRACE_SANITIZE (this); if (unlikely (!sanitize_shallow (c))) return_trace (false); unsigned int count = get_length (); for (unsigned int i = 0; i < count; i++) - if (unlikely (!(*this)[i].sanitize (c, base, ds...))) + if (unlikely (!(*this)[i].sanitize (c, base, hb_forward (ds)...))) return_trace (false); return_trace (true); } diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh index b831ea626..cab444e26 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh @@ -127,7 +127,8 @@ struct hb_serialize_context_t { return propagate_error (!hb_deref_pointer (obj).in_error ()); } template bool propagate_error (T1 &&o1, Ts &&...os) - { return propagate_error (o1) && propagate_error (os...); } + { return propagate_error (hb_forward (o1)) && + propagate_error (hb_forward (os)...); } /* To be called around main operation. */ template