| 194 | */ |
| 195 | template <typename Tag, typename type> |
| 196 | static void |
| 197 | merge_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 |