Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/group/groupwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_set>
#include <vector>

#include <QAction>
Expand Down
19 changes: 19 additions & 0 deletions src/map/roomid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <ostream>

#include <QDebug>

std::ostream &operator<<(std::ostream &os, const RoomId id)
{
return os << "RoomId(" << id.value() << ")";
Expand Down Expand Up @@ -38,3 +40,20 @@ AnsiOstream &operator<<(AnsiOstream &os, const ServerRoomId id)
{
return os << "ServerRoomId(" << id.value() << ")";
}

///

QDebug operator<<(QDebug debug, const RoomId id)
{
return debug << "RoomId(" << id.value() << ")";
}

QDebug operator<<(QDebug debug, const ExternalRoomId id)
{
return debug << "ExternalRoomId(" << id.value() << ")";
}

QDebug operator<<(QDebug debug, const ServerRoomId id)
{
return debug << "ServerRoomId(" << id.value() << ")";
}
5 changes: 5 additions & 0 deletions src/map/roomid.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <cstdint>
#include <ostream>

#include <QDebug>

class AnsiOstream;

namespace tags {
Expand All @@ -31,6 +33,7 @@ struct NODISCARD RoomId final : public TaggedInt<RoomId, tags::RoomIdTag, uint32
NODISCARD constexpr uint32_t asUint32() const { return value(); }
friend std::ostream &operator<<(std::ostream &os, RoomId id);
friend AnsiOstream &operator<<(AnsiOstream &os, RoomId id);
friend QDebug operator<<(QDebug debug, RoomId id);
};

struct NODISCARD ExternalRoomId final
Expand All @@ -43,6 +46,7 @@ struct NODISCARD ExternalRoomId final
NODISCARD constexpr uint32_t asUint32() const { return value(); }
friend std::ostream &operator<<(std::ostream &os, ExternalRoomId id);
friend AnsiOstream &operator<<(AnsiOstream &os, ExternalRoomId id);
friend QDebug operator<<(QDebug debug, ExternalRoomId id);
};

struct NODISCARD ServerRoomId final
Expand All @@ -55,6 +59,7 @@ struct NODISCARD ServerRoomId final
NODISCARD constexpr uint32_t asUint32() const { return value(); }
friend std::ostream &operator<<(std::ostream &os, ServerRoomId id);
friend AnsiOstream &operator<<(AnsiOstream &os, ServerRoomId id);
friend QDebug operator<<(QDebug debug, ServerRoomId id);
};

static_assert(sizeof(RoomId) == sizeof(uint32_t));
Expand Down
36 changes: 28 additions & 8 deletions src/mapdata/GenericFind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,37 @@

#include "GenericFind.h"

#include "../global/Timer.h"
#include "../global/thread_utils.h"
#include "../map/Map.h"
#include "roomfilter.h"

RoomIdSet genericFind(const Map &map, const RoomFilter &f)
{
RoomIdSet result;
map.getRooms().for_each([&result, &map, &f](const RoomId id) {
const auto &room = map.getRawRoom(id);
if (f.filter(room)) {
result.insert(id);
}
});
return result;
DECL_TIMER(t, "genericFind (parallel)");

struct TlData final
{
RoomIdSet result;
};

ProgressCounter pc;
TlData tl_data;

thread_utils::parallel_for_each_tl<TlData>(
map.getRooms(),
pc,
[&map, &f](TlData &tl, const RoomId id) {
const auto &room = map.getRawRoom(id);
if (f.filter(room)) {
tl.result.insert(id);
}
},
[&tl_data](auto &tls) {
for (auto &tl : tls) {
tl_data.result.insertAll(tl.result);
}
});

return tl_data.result;
}
Loading
Loading