Skip to content

Commit 26767e1

Browse files
committed
modernize SwapBufferGuard
1 parent 40e2b01 commit 26767e1

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

sources/libcore/swapBufferGuard.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace cage
1717
class SwapBufferGuardImpl : public SwapBufferGuard
1818
{
1919
public:
20-
explicit SwapBufferGuardImpl(const SwapBufferGuardCreateConfig &config) : states{ StateEnum::Nothing, StateEnum::Nothing, StateEnum::Nothing, StateEnum::Nothing }, ri(0), wi(0), buffersCount(config.buffersCount), repeatedReads(config.repeatedReads), repeatedWrites(config.repeatedWrites)
20+
explicit SwapBufferGuardImpl(const SwapBufferGuardCreateConfig &config) : buffersCount(config.buffersCount), repeatedReads(config.repeatedReads), repeatedWrites(config.repeatedWrites)
2121
{
2222
CAGE_ASSERT(buffersCount > 1 && buffersCount < 5);
2323
CAGE_ASSERT(buffersCount > 1u + repeatedReads + repeatedWrites);
@@ -118,11 +118,9 @@ namespace cage
118118

119119
uint32 next(uint32 i) const { return (i + 1) % buffersCount; }
120120

121-
uint32 prev(uint32 i) const { return (i + buffersCount - 1) % buffersCount; }
122-
123121
Holder<Mutex> mutex;
124-
StateEnum states[4];
125-
uint32 ri, wi;
122+
StateEnum states[4] = { StateEnum::Nothing, StateEnum::Nothing, StateEnum::Nothing, StateEnum::Nothing };
123+
uint32 ri = 0, wi = 0;
126124
const uint32 buffersCount;
127125
const bool repeatedReads, repeatedWrites;
128126
};
@@ -179,9 +177,6 @@ namespace cage
179177
return impl->write();
180178
}
181179

182-
//SwapBufferGuardCreateConfig::SwapBufferGuardCreateConfig(uint32 buffersCount) : buffersCount(buffersCount)
183-
//{}
184-
185180
Holder<SwapBufferGuard> newSwapBufferGuard(const SwapBufferGuardCreateConfig &config)
186181
{
187182
return systemMemory().createImpl<SwapBufferGuard, SwapBufferGuardImpl>(config);

sources/libsimple/sound.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ namespace cage
3535
struct EmitSound
3636
{
3737
TransformComponent transform, transformHistory;
38-
SoundComponent sound = {};
38+
SoundComponent sound;
3939
uintPtr id = 0;
4040
};
4141

4242
struct EmitListener
4343
{
4444
TransformComponent transform, transformHistory;
45-
ListenerComponent listener = {};
45+
ListenerComponent listener;
4646
uintPtr id = 0;
4747
};
4848

0 commit comments

Comments
 (0)