Skip to content

Commit 4a5f084

Browse files
committed
minor cleanups
1 parent 04947cd commit 4a5f084

11 files changed

Lines changed: 34 additions & 25 deletions

File tree

src/client/PaletteManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class NODISCARD PaletteManager final
2424
private:
2525
QPalette m_focused;
2626
QPalette m_unfocused;
27-
MAYBE_UNUSED bool m_initialized = false;
27+
bool m_initialized = false;
2828

2929
public:
3030
void init(QWidget &widget, const std::optional<QColor> &activeBg, const QColor &inactiveBg);

src/global/AnsiTextUtils.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,14 @@ struct NODISCARD AnsiItuColorCodes final
589589
NODISCARD int operator[](const size_t pos) const { return at(pos); }
590590

591591
public:
592-
class NODISCARD ConstIterator final
592+
class ALLOW_DISCARD ConstIterator final
593593
{
594594
private:
595595
const AnsiItuColorCodes *m_self = nullptr;
596596
uint8_t m_pos = 0;
597597

598598
public:
599-
explicit ConstIterator(const AnsiItuColorCodes *const self, const uint8_t pos)
599+
NODISCARD explicit ConstIterator(const AnsiItuColorCodes *const self, const uint8_t pos)
600600
: m_self{self}
601601
, m_pos{pos}
602602
{
@@ -607,7 +607,8 @@ struct NODISCARD AnsiItuColorCodes final
607607
NODISCARD const AnsiItuColorCodes &getSelf() const { return deref(m_self); }
608608

609609
public:
610-
NODISCARD ConstIterator operator++()
610+
void operator++(int) = delete;
611+
ALLOW_DISCARD ConstIterator operator++()
611612
{
612613
if (m_pos >= getSelf().size()) {
613614
throw std::runtime_error("invalid increment");

src/global/ConversionResult.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77

88
#include <type_traits>
99

10+
#ifdef __clang__
11+
#pragma clang diagnostic push
12+
#pragma clang diagnostic ignored "-Wpadded"
13+
#endif
1014
template<typename T>
1115
class NODISCARD ConversionResult final
1216
{
1317
private:
1418
T m_value{};
1519
CastErrorEnum m_result = CastErrorEnum::Success;
1620

17-
// This is just to avoid a padding warning
18-
static inline constexpr auto PAD_BYTES = (alignof(T) > sizeof(CastErrorEnum))
19-
? (alignof(T) - sizeof(CastErrorEnum))
20-
: alignof(T);
21-
MAYBE_UNUSED char m_unused_pad[PAD_BYTES]{};
22-
2321
public:
2422
constexpr explicit ConversionResult(const T n) noexcept
2523
: m_value{n}
@@ -60,3 +58,6 @@ class NODISCARD ConversionResult final
6058
return is_valid() && m_value == intValue;
6159
}
6260
};
61+
#ifdef __clang__
62+
#pragma clang diagnostic pop
63+
#endif

src/global/Flags.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,14 @@ class NODISCARD Flags
273273
}
274274

275275
public:
276-
struct NODISCARD Iterator final
276+
struct ALLOW_DISCARD Iterator final
277277
{
278278
private:
279279
Flags::underlying_type m_bits = 0;
280280
size_t m_pos = 0;
281281

282282
public:
283-
Iterator(const Flags flags, const size_t pos)
283+
NODISCARD Iterator(const Flags flags, const size_t pos)
284284
: m_bits{flags.m_flags}
285285
, m_pos{pos}
286286
{}

src/global/cast_error.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ enum class NODISCARD CastErrorEnum : uint8_t {
1616
RoundTripFailure,
1717
};
1818

19+
#ifdef __clang__
20+
#pragma clang diagnostic push
21+
#pragma clang diagnostic ignored "-Wpadded"
22+
#endif
1923
struct NODISCARD CastErrorException : public std::runtime_error
2024
{
2125
CastErrorEnum err = CastErrorEnum::Success;
2226

23-
// This is just to avoid a padding warning.
24-
static_assert(alignof(std::runtime_error) > sizeof(CastErrorEnum));
25-
MAYBE_UNUSED char unused_pad[alignof(std::runtime_error) - sizeof(CastErrorEnum)]{};
26-
2727
explicit CastErrorException(const CastErrorEnum e)
2828
: std::runtime_error{"CastErrorException"}
2929
, err{e}
@@ -32,3 +32,6 @@ struct NODISCARD CastErrorException : public std::runtime_error
3232
}
3333
~CastErrorException() override;
3434
};
35+
#ifdef __clang__
36+
#pragma clang diagnostic pop
37+
#endif

src/map/ChangePrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct NODISCARD ChangePrinter::StructHelper final
6161
m_cp.print(std::forward<V>(value));
6262
}
6363

64-
explicit operator bool() const { return true; }
64+
NODISCARD explicit operator bool() const { return true; }
6565
};
6666

6767
#define BEGIN_FLAGS_HELPER(name) if (FlagsHelper helper{*this, name})
@@ -96,7 +96,7 @@ struct NODISCARD ChangePrinter::FlagsHelper final
9696
m_cp.print(std::forward<T>(thing));
9797
}
9898

99-
explicit operator bool() const { return true; }
99+
NODISCARD explicit operator bool() const { return true; }
100100
};
101101

102102
ChangePrinter::ChangePrinter(Remap remap, AnsiOstream &os)

src/map/Map.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include <ostream>
2020
#include <vector>
2121

22+
namespace mm {
23+
struct AbstractDebugOStream;
24+
}
2225
class AnsiOstream;
2326
class Change;
2427
class ChangeList;
@@ -141,8 +144,9 @@ class NODISCARD Map final
141144

142145
struct NODISCARD MapApplyResult final
143146
{
147+
static inline constexpr auto ALL_ROOM_UPDATE_FLAGS = ~RoomUpdateFlags{};
144148
Map map;
145-
RoomUpdateFlags roomUpdateFlags = ~RoomUpdateFlags{};
149+
RoomUpdateFlags roomUpdateFlags = ALL_ROOM_UPDATE_FLAGS;
146150
};
147151

148152
struct NODISCARD MapPair final

src/map/World.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,9 +1394,9 @@ RoomId World::convertToInternal(const ExternalRoomId ext) const
13941394
return m_remapping.convertToInternal(ext);
13951395
}
13961396

1397-
ExternalRoomId World::convertToExternal(const RoomId ext) const
1397+
ExternalRoomId World::convertToExternal(const RoomId id) const
13981398
{
1399-
return m_remapping.convertToExternal(ext);
1399+
return m_remapping.convertToExternal(id);
14001400
}
14011401

14021402
void World::apply(ProgressCounter &pc, const world_change_types::CompactRoomIds &change)

src/map/World.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class NODISCARD World final
147147
NODISCARD ExternalRawRoom convertToExternal(const RawRoom &room) const;
148148

149149
NODISCARD RoomId convertToInternal(ExternalRoomId ext) const;
150-
NODISCARD ExternalRoomId convertToExternal(RoomId ext) const;
150+
NODISCARD ExternalRoomId convertToExternal(RoomId id) const;
151151

152152
public:
153153
void applyOne(ProgressCounter &pc, const Change &change);

src/mapfrontend/mapfrontend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void MapFrontend::setCurrentMap(const MapApplyResult &result)
219219
void MapFrontend::setCurrentMap(Map map)
220220
{
221221
// Always update everything when the map is changed like this.
222-
setCurrentMap(MapApplyResult{map, ~RoomUpdateFlags{}});
222+
setCurrentMap(MapApplyResult{std::move(map)});
223223
}
224224

225225
bool MapFrontend::applySingleChange(ProgressCounter &pc, const Change &change)

0 commit comments

Comments
 (0)