Commit d08996a
committed
Get rid of bounds check in slice::chunks_exact() and related functions during construction
LLVM can't figure out in
let rem = self.len() % chunk_size;
let len = self.len() - rem;
let (fst, snd) = self.split_at(len);
and
let rem = self.len() % chunk_size;
let (fst, snd) = self.split_at(rem);
that the index passed to split_at() is smaller than the slice length and
adds a bounds check plus panic for it.
Apart from removing the overhead of the bounds check this also allows
LLVM to optimize code around the ChunksExact iterator better.1 parent 30dc32b commit d08996a
1 file changed
+10
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
868 | | - | |
869 | | - | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
| |||
910 | 911 | | |
911 | 912 | | |
912 | 913 | | |
913 | | - | |
914 | | - | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
915 | 917 | | |
916 | 918 | | |
917 | 919 | | |
| |||
1063 | 1065 | | |
1064 | 1066 | | |
1065 | 1067 | | |
1066 | | - | |
| 1068 | + | |
| 1069 | + | |
1067 | 1070 | | |
1068 | 1071 | | |
1069 | 1072 | | |
| |||
1108 | 1111 | | |
1109 | 1112 | | |
1110 | 1113 | | |
1111 | | - | |
| 1114 | + | |
| 1115 | + | |
1112 | 1116 | | |
1113 | 1117 | | |
1114 | 1118 | | |
| |||
0 commit comments