reserve capacity in advance of loop
This commit is contained in:
parent
f0eda085f0
commit
48842457c1
3
ml.cpp
3
ml.cpp
|
|
@ -1941,7 +1941,8 @@ MlValue range(std::vector<MlValue> args, MlEnvironment &env) {
|
||||||
|
|
||||||
if (low >= high) return MlValue(result);
|
if (low >= high) return MlValue(result);
|
||||||
|
|
||||||
while (low < high) {
|
result.reserve(high.as_int() - low.as_int());
|
||||||
|
while (low < high) { // use MlValue to keep number datatype
|
||||||
result.push_back(low);
|
result.push_back(low);
|
||||||
low = low + MlValue(1l);
|
low = low + MlValue(1l);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue