Revert "[iter] Rewrite some loops as range loops"

This reverts commit 7a5242a30f.

This times out test-set. Obviously broke something (in hb_all
I think). Not bothering to figure out right now.
pull/4271/head
Behdad Esfahbod 1 year ago
parent 7a5242a30f
commit 78082357c8
  1. 35
      src/hb-iter.hh

@ -496,8 +496,8 @@ struct hb_reduce_t
operator () (Iter it) operator () (Iter it)
{ {
AccuT value = init_value; AccuT value = init_value;
for (const auto &_ : it) for (; it; ++it)
value = r (value, _); value = r (value, *it);
return value; return value;
} }
@ -679,8 +679,8 @@ struct hb_apply_t
hb_requires (hb_is_iterator (Iter))> hb_requires (hb_is_iterator (Iter))>
void operator () (Iter it) void operator () (Iter it)
{ {
for (const auto &_ : it) for (; it; ++it)
(void) hb_invoke (a, _); (void) hb_invoke (a, *it);
} }
private: private:
@ -879,8 +879,8 @@ struct hb_sink_t
hb_requires (hb_is_iterator (Iter))> hb_requires (hb_is_iterator (Iter))>
void operator () (Iter it) void operator () (Iter it)
{ {
for (const auto &_ : it) for (; it; ++it)
s << _; s << *it;
} }
private: private:
@ -906,8 +906,8 @@ struct
hb_requires (hb_is_iterator (Iter))> hb_requires (hb_is_iterator (Iter))>
void operator () (Iter it) const void operator () (Iter it) const
{ {
for (const auto &_ : it) for (; it; ++it)
(void) _; (void) *it;
} }
} }
HB_FUNCOBJ (hb_drain); HB_FUNCOBJ (hb_drain);
@ -923,10 +923,11 @@ struct hb_unzip_t
hb_requires (hb_is_iterator (Iter))> hb_requires (hb_is_iterator (Iter))>
void operator () (Iter it) void operator () (Iter it)
{ {
for (const auto &_ : it) for (; it; ++it)
{ {
s1 << _.first; const auto &v = *it;
s2 << _.second; s1 << v.first;
s2 << v.second;
} }
} }
@ -959,8 +960,8 @@ struct
Pred&& p = hb_identity, Pred&& p = hb_identity,
Proj&& f = hb_identity) const Proj&& f = hb_identity) const
{ {
for (auto _ : c) for (auto it = hb_iter (c); it; ++it)
if (!hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), _))) if (!hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it)))
return false; return false;
return true; return true;
} }
@ -976,8 +977,8 @@ struct
Pred&& p = hb_identity, Pred&& p = hb_identity,
Proj&& f = hb_identity) const Proj&& f = hb_identity) const
{ {
for (auto _ : c) for (auto it = hb_iter (c); it; ++it)
if (hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), _))) if (hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it)))
return true; return true;
return false; return false;
} }
@ -993,8 +994,8 @@ struct
Pred&& p = hb_identity, Pred&& p = hb_identity,
Proj&& f = hb_identity) const Proj&& f = hb_identity) const
{ {
for (auto _ : c) for (auto it = hb_iter (c); it; ++it)
if (hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), _))) if (hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it)))
return false; return false;
return true; return true;
} }

Loading…
Cancel
Save