summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-07-26 21:04:02 +1000
committerMaxime Coste <mawww@kakoune.org>2018-07-26 21:23:06 +1000
commit737807dde28e55a7665eac43b7176cd2cc899d67 (patch)
tree6211183deea26e064c6463c132b108867ebb1fe6 /src
parent0919679e0d83132935d787a4470ea9164cd7eac5 (diff)
Replace a few loops with ranges
Diffstat (limited to 'src')
-rw-r--r--src/highlighters.cc9
-rw-r--r--src/main.cc10
-rw-r--r--src/normal.cc2
3 files changed, 9 insertions, 12 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc
index a2987909..0fc69826 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -273,12 +273,9 @@ public:
if (not overlaps(display_buffer.range(), range))
return;
- Vector<Face> faces(m_faces.size());
- for (int f = 0; f < m_faces.size(); ++f)
- {
- if (not m_faces[f].second.empty())
- faces[f] = context.context.faces()[m_faces[f].second];
- }
+ const auto faces = m_faces | transform([&faces = context.context.faces()](auto&& spec) {
+ return spec.second.empty() ? Face{} : faces[spec.second];
+ }) | gather<Vector<Face>>();
auto& matches = get_matches(context.context.buffer(), display_buffer.range(), range);
kak_assert(matches.size() % m_faces.size() == 0);
diff --git a/src/main.cc b/src/main.cc
index 27c144ae..1acfdd34 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -899,10 +899,6 @@ int main(int argc, char* argv[])
set_signal_handler(SIGINT, [](int){});
set_signal_handler(SIGCHLD, [](int){});
- Vector<String> params;
- for (int i = 1; i < argc; ++i)
- params.emplace_back(argv[i]);
-
const ParameterDesc param_desc{
SwitchMap{ { "c", { true, "connect to given session" } },
{ "e", { true, "execute argument on client initialisation" } },
@@ -936,7 +932,11 @@ int main(int argc, char* argv[])
return 0;
};
- if (contains(ConstArrayView<char*>{argv+1, (size_t)argc-1}, "--help"_sv))
+ const auto params = ArrayView<char*>{argv+1, argv + argc}
+ | transform([](auto* s) { return String{s}; })
+ | gather<Vector<String>>();
+
+ if (contains(params, "--help"_sv))
return show_usage();
ParametersParser parser{params, param_desc};
diff --git a/src/normal.cc b/src/normal.cc
index a1c14604..f0ab0155 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -167,7 +167,7 @@ String build_autoinfo_for_mapping(Context& context, KeymapMode mode,
{
String keys = join(built_in.keys |
filter([&](Key k){ return not keymaps.is_mapped(k, mode); }) |
- transform([](Key k) { return key_to_str(k); }),
+ transform(key_to_str),
',', false);
if (not keys.empty())
descs.emplace_back(std::move(keys), built_in.docstring);