@@ -40,20 +40,27 @@ pub fn sort<T, F: FnMut(&T, &T) -> bool, BufT: BufGuard>(v: &mut [T], is_less |
|
|
40 |
40 |
} |
41 |
41 |
|
42 |
42 |
cfg_if! { |
43 |
|
-if #[cfg(feature = "optimize_for_size")] { |
|
43 |
+if #[cfg(any(feature = "optimize_for_size", target_pointer_width = "16"))] { |
44 |
44 |
let alloc_len = len / 2; |
45 |
45 |
|
46 |
|
-// For small inputs 4KiB of stack storage suffices, which allows us to avoid |
47 |
|
-// calling the (de-)allocator. Benchmarks showed this was quite beneficial. |
48 |
|
-let mut stack_buf = AlignedStorage::<T, 4096>::new(); |
49 |
|
-let stack_scratch = stack_buf.as_uninit_slice_mut(); |
50 |
|
-let mut heap_buf; |
51 |
|
-let scratch = if stack_scratch.len() >= alloc_len { |
52 |
|
- stack_scratch |
53 |
|
-} else { |
54 |
|
- heap_buf = BufT::with_capacity(alloc_len); |
55 |
|
- heap_buf.as_uninit_slice_mut() |
56 |
|
-}; |
|
46 |
+ cfg_if! { |
|
47 |
+if #[cfg(target_pointer_width = "16")] { |
|
48 |
+let heap_buf = BufT::with_capacity(alloc_len); |
|
49 |
+let scratch = heap_buf.as_uninit_slice_mut(); |
|
50 |
+} else { |
|
51 |
+// For small inputs 4KiB of stack storage suffices, which allows us to avoid |
|
52 |
+// calling the (de-)allocator. Benchmarks showed this was quite beneficial. |
|
53 |
+let mut stack_buf = AlignedStorage::<T, 4096>::new(); |
|
54 |
+let stack_scratch = stack_buf.as_uninit_slice_mut(); |
|
55 |
+let mut heap_buf; |
|
56 |
+let scratch = if stack_scratch.len() >= alloc_len { |
|
57 |
+ stack_scratch |
|
58 |
+} else { |
|
59 |
+ heap_buf = BufT::with_capacity(alloc_len); |
|
60 |
+ heap_buf.as_uninit_slice_mut() |
|
61 |
+}; |
|
62 |
+} |
|
63 |
+} |
57 |
64 |
|
58 |
65 |
tiny::mergesort(v, scratch, is_less); |
59 |
66 |
} else { |