MCPcopy Create free account
hub / github.com/numpy/numpy / merge_left_

Function merge_left_

numpy/core/src/npysort/timsort.cpp:196–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194 */
195template <typename Tag, typename type>
196static void
197merge_left_(type *p1, npy_intp l1, type *p2, npy_intp l2, type *p3)
198{
199 type *end = p2 + l2;
200 memcpy(p3, p1, sizeof(type) * l1);
201 /* first element must be in p2 otherwise skipped in the caller */
202 *p1++ = *p2++;
203
204 while (p1 < p2 && p2 < end) {
205 if (Tag::less(*p2, *p3)) {
206 *p1++ = *p2++;
207 }
208 else {
209 *p1++ = *p3++;
210 }
211 }
212
213 if (p1 != p2) {
214 memcpy(p1, p3, sizeof(type) * (p2 - p1));
215 }
216}
217
218/* when the right part of the array (p2) is smaller, copy p2 to buffer
219 * and merge from right to left

Callers

nothing calls this directly

Calls 2

lessFunction · 0.50
copyFunction · 0.50

Tested by

no test coverage detected