From 8a8d45b924cdb4343b4b11a7ef14e2d1fabb6f82 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 31 Mar 2019 19:00:09 -0700 Subject: [PATCH] [iter] Adjust hb_copy() and use it Untested. --- src/hb-iter.hh | 11 ++++------- src/hb-vector.hh | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 203a3c7..18b9c4a 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -585,14 +585,11 @@ hb_fill (C& c, const V &v) *i = v; } -template -inline bool -hb_copy (D id, S is) +template +inline void +hb_copy (D&& id, S&& is) { - for (; id && is; ++id, ++is) - *id = *is; - return !is; + hb_iter (id) | hb_sink (is); } diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 4621b51..b5ac738 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -43,7 +43,7 @@ struct hb_vector_t { init (); alloc (o.length); - hb_iter (o) | hb_sink (this); + hb_copy (o, *this); } hb_vector_t (hb_vector_t &&o) { @@ -87,7 +87,7 @@ struct hb_vector_t { reset (); alloc (o.length); - hb_iter (o) | hb_sink (this); + hb_copy (o, *this); return *this; } hb_vector_t& operator = (hb_vector_t &&o) -- 2.7.4