Skip to content

Commit 746c513

Browse files
committed
contrib/sort: Simplify SortDescending in emulated order
1 parent 9282c16 commit 746c513

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

hwy/contrib/sort/order-emulate-inl.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,49 +165,50 @@ struct OrderEmulate : public Base {
165165

166166
template <class Base>
167167
struct OrderEmulate<Base, SortDescending> : public OrderEmulate<Base, SortAscending> {
168-
using _AscBase = OrderEmulate<Base, SortAscending>;
169-
using _Asc = const _AscBase*;
170168
using T = typename Base::LaneType;
171-
using TF = typename Base::KeyType;
169+
170+
HWY_INLINE const OrderEmulate<Base, SortAscending>& AscBase() const {
171+
return *this;
172+
}
172173

173174
HWY_INLINE bool Compare1(const T* a, const T* b) const {
174-
return reinterpret_cast<_Asc>(this)->Compare1(b, a);
175+
return AscBase().Compare1(b, a);
175176
}
176177
template <class D>
177178
HWY_INLINE Mask<D> Compare(D d, Vec<D> a, Vec<D> b) const {
178-
return reinterpret_cast<_Asc>(this)->Compare(d, b, a);
179+
return AscBase().Compare(d, b, a);
179180
}
180181

181182
template <class D>
182183
HWY_INLINE Vec<D> First(D d, const Vec<D> a, const Vec<D> b) const {
183-
return reinterpret_cast<_Asc>(this)->Last(d, a, b);
184+
return AscBase().Last(d, a, b);
184185
}
185186

186187
template <class D>
187188
HWY_INLINE Vec<D> Last(D d, const Vec<D> a, const Vec<D> b) const {
188-
return reinterpret_cast<_Asc>(this)->First(d, a, b);
189+
return AscBase().First(d, a, b);
189190
}
190191

191192
template <class D>
192193
HWY_INLINE Vec<D> FirstOfLanes(D d, Vec<D> v,
193194
T* HWY_RESTRICT b) const {
194-
return reinterpret_cast<_Asc>(this)->LastOfLanes(d, v, b);
195+
return AscBase().LastOfLanes(d, v, b);
195196
}
196197

197198
template <class D>
198199
HWY_INLINE Vec<D> LastOfLanes(D d, Vec<D> v,
199200
T* HWY_RESTRICT b) const {
200-
return reinterpret_cast<_Asc>(this)->FirstOfLanes(d, v, b);
201+
return AscBase().FirstOfLanes(d, v, b);
201202
}
202203

203204
template <class D>
204205
HWY_INLINE Vec<D> FirstValue(D d) const {
205-
return reinterpret_cast<_Asc>(this)->LastValue(d);
206+
return AscBase().LastValue(d);
206207
}
207208

208209
template <class D>
209210
HWY_INLINE Vec<D> LastValue(D d) const {
210-
return reinterpret_cast<_Asc>(this)->FirstValue(d);
211+
return AscBase().FirstValue(d);
211212
}
212213

213214
template <class D, class V = Vec<D>>

0 commit comments

Comments
 (0)