Skip to content

Commit 4e20616

Browse files
committed
refactor: we cannot use C++20 feature std::views::filter as it's not supported by older compilers that are supposed to "support C++20"
See https://en.cppreference.com/w/cpp/ranges/filter_view for the library reference See https://en.cppreference.com/w/cpp/compiler_support/20 for compiler support: The One Ranges Proposal | GCC 10 | Clang 13 (partial) 15 | MSVC 19.29 (16.10)* | Apple Clang 14.0.3
1 parent 94a8e43 commit 4e20616

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

include/PyEventLoop.hh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <vector>
1717
#include <utility>
1818
#include <atomic>
19-
#include <ranges>
2019

2120
struct PyEventLoop {
2221
public:
@@ -140,14 +139,10 @@ public:
140139
}
141140

142141
/**
143-
* @brief Get an iterator for the `AsyncHandle`s of all ref'ed timers
142+
* @brief Get an iterator for the `AsyncHandle`s of all timers
144143
*/
145-
static inline auto getAllRefed() {
146-
return std::views::filter(_timeoutIdMap,
147-
[](AsyncHandle &timer) {
148-
return timer.hasRef();
149-
}
150-
);
144+
static inline auto &getAllTimers() {
145+
return _timeoutIdMap;
151146
}
152147
protected:
153148
PyObject *_handle;

src/internalBinding/timers.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ static bool getAllRefedTimersDebugInfo(JSContext *cx, unsigned argc, JS::Value *
120120
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
121121

122122
JS::RootedVector<JS::Value> results(cx);
123-
for (AsyncHandle &timer: AsyncHandle::getAllRefed()) {
123+
for (AsyncHandle &timer: AsyncHandle::getAllTimers()) {
124+
if (!timer.hasRef()) continue; // we only need ref'ed timers
125+
124126
JS::Value debugInfo = jsTypeFactory(cx, timer.getDebugInfo());
125127
if (!results.append(debugInfo)) {
126128
// out of memory

0 commit comments

Comments
 (0)