Skip to content

Commit

Permalink
Merged revision(s) 21989 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Ref] mpt/io_write/buffer.hpp: Fix formatting which clang-format misses.
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.30@21991 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
manxorist committed Oct 26, 2024
1 parent 54ccfe1 commit 6569d7c
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/mpt/io_write/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ class WriteBuffer {
inline WriteBuffer(Tfile & f_, mpt::byte_span buffer_)
: buffer(buffer_)
, f(f_) {
return;
}
inline ~WriteBuffer() noexcept(false) {
if (!writeError)
{
if (!writeError) {
FlushLocal();
}
}

public:
inline Tfile & file() const {
if (IsDirty())
{
if (IsDirty()) {
FlushLocal();
}
return f;
Expand All @@ -84,30 +83,24 @@ class WriteBuffer {
}
inline bool Write(mpt::const_byte_span data) {
bool result = true;
for (std::size_t i = 0; i < data.size(); ++i)
{
for (std::size_t i = 0; i < data.size(); ++i) {
buffer[size] = data[i];
size++;
if (IsFull())
{
if (IsFull()) {
FlushLocal();
}
}
return result;
}
inline void FlushLocal() {
if (IsClean())
{
if (IsClean()) {
return;
}
try
{
if (!mpt::IO::WriteRaw(f, mpt::as_span(buffer.data(), size)))
{
try {
if (!mpt::IO::WriteRaw(f, mpt::as_span(buffer.data(), size))) {
writeError = true;
}
} catch (const std::exception &)
{
} catch (const std::exception &) {
writeError = true;
throw;
}
Expand Down

0 comments on commit 6569d7c

Please sign in to comment.