From 3c8a9e52743b8f736b9bda569c384402b63eb0ec Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 18 Jul 2021 17:30:07 -0400 Subject: [PATCH] Replace macro ADC with a plain old function hr::span_at. --- graph.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/graph.cpp b/graph.cpp index 2cb48666..59260df7 100644 --- a/graph.cpp +++ b/graph.cpp @@ -45,7 +45,24 @@ EX bool hide_player() { ; } -#define ADC(V,c) if (auto *it = hr::find_or_null(current_display->all_drawn_copies, c)) for(const shiftmatrix& V: it->second) +template +class span { + T *begin_ = nullptr; + T *end_ = nullptr; + + public: + explicit span() = default; + explicit span(T *p, int n) : begin_(p), end_(p + n) {} + T *begin() const { return begin_; } + T *end() const { return end_; } + }; + +template +hr::span span_at(const Map& map, const Key& key) { + auto it = map.find(key); + return (it == map.end()) ? hr::span() : hr::span(it->second.data(), it->second.size()); + } +#define ADC(V,c) for (const shiftmatrix& V : hr::span_at(current_display->all_drawn_copies, c)) EX hookset hooks_handleKey; EX hookset hooks_drawcell;