reserve vactor size in map
This commit is contained in:
parent
28c6023f7d
commit
3b89b61d66
1
ml.cpp
1
ml.cpp
|
|
@ -1879,6 +1879,7 @@ MlValue map_list(std::vector<MlValue> args, MlEnvironment &env) {
|
||||||
throw MlError(MlValue("map_list", map_list), env, args.size() > 2 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
|
throw MlError(MlValue("map_list", map_list), env, args.size() > 2 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
|
||||||
|
|
||||||
std::vector<MlValue> result, list = args[1].as_list(), tmp;
|
std::vector<MlValue> result, list = args[1].as_list(), tmp;
|
||||||
|
result.reserve(list.size());
|
||||||
for (const auto & item : list) {
|
for (const auto & item : list) {
|
||||||
tmp.push_back(item);
|
tmp.push_back(item);
|
||||||
result.push_back(args[0].apply(tmp, env));
|
result.push_back(args[0].apply(tmp, env));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue