From 73699bd1cf7450a09247f236edf29847bef54449 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 18 Feb 2017 17:49:01 +0100 Subject: [PATCH] use std::min, max, clamp --- src/cs_vm.cc | 6 +++--- src/cubescript.cc | 4 ++-- src/lib_list.cc | 10 +++++----- src/lib_str.cc | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cs_vm.cc b/src/cs_vm.cc index 7c7ca63..3b01700 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -82,7 +82,7 @@ cs_stack_state cs_error::save_stack(cs_state &cs) { return cs_stack_state(cs, nullptr, false); } cs_stack_state_node *st = cs.p_state->create_array( - ostd::min(total, dalias->get_value()) + std::min(total, dalias->get_value()) ); cs_stack_state_node *ret = st, *nd = st; ++st; @@ -429,7 +429,7 @@ static inline void callcommand( args[i].set_int(cs_int(lookup ? -1 : i - fakeargs)); break; case 'C': { - i = ostd::max(i + 1, numargs); + i = std::max(i + 1, numargs); auto buf = ostd::appender_range{}; cscript::util::tvals_concat(buf, ostd::iter(args, args + i), " "); cs_value tv; @@ -438,7 +438,7 @@ static inline void callcommand( return; } case 'V': - i = ostd::max(i + 1, numargs); + i = std::max(i + 1, numargs); cs_cmd_internal::call(cs, id, ostd::iter(args, args + i), res); return; case '1': diff --git a/src/cubescript.cc b/src/cubescript.cc index 61cfab4..b6d3e60 100644 --- a/src/cubescript.cc +++ b/src/cubescript.cc @@ -736,7 +736,7 @@ void cs_state::set_var_int( [&iv]() { iv->p_overrideval = iv->get_value(); } ); if (doclamp) { - iv->set_value(ostd::clamp(v, iv->get_val_min(), iv->get_val_max())); + iv->set_value(std::clamp(v, iv->get_val_min(), iv->get_val_max())); } else { iv->set_value(v); } @@ -758,7 +758,7 @@ void cs_state::set_var_float( [&fv]() { fv->p_overrideval = fv->get_value(); } ); if (doclamp) { - fv->set_value(ostd::clamp(v, fv->get_val_min(), fv->get_val_max())); + fv->set_value(std::clamp(v, fv->get_val_min(), fv->get_val_max())); } else { fv->set_value(v); } diff --git a/src/lib_list.cc b/src/lib_list.cc index d5da9a4..2f5aa1e 100644 --- a/src/lib_list.cc +++ b/src/lib_list.cc @@ -171,8 +171,8 @@ void cs_init_lib_list(cs_state &gcs) { count = args[2].get_int(), numargs = args[3].get_int(); - cs_int offset = ostd::max(skip, cs_int(0)), - len = (numargs >= 3) ? ostd::max(count, cs_int(0)) : -1; + cs_int offset = std::max(skip, cs_int(0)), + len = (numargs >= 3) ? std::max(count, cs_int(0)) : -1; util::ListParser p(cs, args[0].get_strr()); for (cs_int i = 0; i < offset; ++i) { @@ -466,8 +466,8 @@ end: }); gcs.new_command("listsplice", "ssii", [](auto &cs, auto args, auto &res) { - cs_int offset = ostd::max(args[2].get_int(), cs_int(0)); - cs_int len = ostd::max(args[3].get_int(), cs_int(0)); + cs_int offset = std::max(args[2].get_int(), cs_int(0)); + cs_int len = std::max(args[3].get_int(), cs_int(0)); ostd::string_range s = args[0].get_strr(); ostd::string_range vals = args[1].get_strr(); char const *list = s.data(); @@ -606,7 +606,7 @@ static void cs_list_sort( yval.pop(); cs_string sorted; - sorted.reserve(totaluniq + ostd::max(nuniq - 1, size_t(0))); + sorted.reserve(totaluniq + std::max(nuniq - 1, size_t(0))); for (size_t i = 0; i < items.size(); ++i) { ListSortItem &item = items[i]; if (item.quote.empty()) { diff --git a/src/lib_str.cc b/src/lib_str.cc index 6f45b91..6287216 100644 --- a/src/lib_str.cc +++ b/src/lib_str.cc @@ -125,7 +125,7 @@ void cs_init_lib_string(cs_state &cs) { auto r = ostd::appender_range{}; try { ostd::format( - r, "0x%.*X", ostd::max(args[1].get_int(), cs_int(1)), + r, "0x%.*X", std::max(args[1].get_int(), cs_int(1)), args[0].get_int() ); } catch (ostd::format_error const &e) { @@ -138,11 +138,11 @@ void cs_init_lib_string(cs_state &cs) { ostd::string_range s = args[0].get_strr(); cs_int start = args[1].get_int(), count = args[2].get_int(); cs_int numargs = args[3].get_int(); - cs_int len = cs_int(s.size()), offset = ostd::clamp(start, cs_int(0), len); + cs_int len = cs_int(s.size()), offset = std::clamp(start, cs_int(0), len); res.set_str(cs_string{ &s[offset], (numargs >= 3) - ? size_t(ostd::clamp(count, cs_int(0), len - offset)) + ? size_t(std::clamp(count, cs_int(0), len - offset)) : size_t(len - offset) }); }); @@ -208,8 +208,8 @@ void cs_init_lib_string(cs_state &cs) { ostd::string_range vals = args[1].get_strr(); cs_int skip = args[2].get_int(), count = args[3].get_int(); - cs_int offset = ostd::clamp(skip, cs_int(0), cs_int(s.size())), - len = ostd::clamp(count, cs_int(0), cs_int(s.size()) - offset); + cs_int offset = std::clamp(skip, cs_int(0), cs_int(s.size())), + len = std::clamp(count, cs_int(0), cs_int(s.size()) - offset); cs_string p; p.reserve(s.size() - len + vals.size()); if (offset) {