| 922 | |
| 923 | static struct StringsBuffer* sort_buffer; |
| 924 | static void StringsBuffer_QuickSort(int left, int right) { |
| 925 | struct StringsBuffer* buffer = sort_buffer; |
| 926 | cc_uint32* keys = buffer->flagsBuffer; cc_uint32 key; |
| 927 | |
| 928 | while (left < right) { |
| 929 | int i = left, j = right; |
| 930 | cc_string pivot = StringsBuffer_UNSAFE_Get(buffer, (i + j) >> 1); |
| 931 | cc_string strI, strJ; |
| 932 | |
| 933 | /* partition the list */ |
| 934 | while (i <= j) { |
| 935 | while ((strI = StringsBuffer_UNSAFE_Get(buffer, i), String_Compare(&pivot, &strI)) > 0) i++; |
| 936 | while ((strJ = StringsBuffer_UNSAFE_Get(buffer, j), String_Compare(&pivot, &strJ)) < 0) j--; |
| 937 | QuickSort_Swap_Maybe(); |
| 938 | } |
| 939 | /* recurse into the smaller subset */ |
| 940 | QuickSort_Recurse(StringsBuffer_QuickSort) |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | void StringsBuffer_Sort(struct StringsBuffer* buffer) { |
| 945 | sort_buffer = buffer; |
no test coverage detected