From: Rosen Penev Date: Thu, 29 Sep 2022 23:20:46 +0000 (-0700) Subject: clang-tidy: don't use else after return X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ae618cb5ffd41ef3ac2688848d59b386cfa5f49;p=libmatroska clang-tidy: don't use else after return Less indentation. Signed-off-by: Rosen Penev --- diff --git a/src/KaxBlock.cpp b/src/KaxBlock.cpp index 3a52ef6..9353513 100644 --- a/src/KaxBlock.cpp +++ b/src/KaxBlock.cpp @@ -266,140 +266,139 @@ filepos_t KaxBlockVirtual::UpdateSize(bool /* bSaveDefault */, bool /* bForceRen */ filepos_t KaxInternalBlock::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bSaveDefault */) { - if (myBuffers.empty()) { + if (myBuffers.empty()) return 0; + + assert(TrackNumber < 0x4000); + binary BlockHead[5]; + auto cursor = BlockHead; + unsigned int i; + + if (myBuffers.size() == 1) { + SetSize_(4); + mLacing = LACING_NONE; } else { - assert(TrackNumber < 0x4000); - binary BlockHead[5]; - auto cursor = BlockHead; - unsigned int i; - - if (myBuffers.size() == 1) { - SetSize_(4); - mLacing = LACING_NONE; - } else { - if (mLacing == LACING_NONE) - mLacing = LACING_EBML; // supposedly the best of all - SetSize_(4 + 1); // 1 for the lacing head (number of laced elements) - } - if (TrackNumber >= 0x80) - SetSize_(GetSize() + 1); + if (mLacing == LACING_NONE) + mLacing = LACING_EBML; // supposedly the best of all + SetSize_(4 + 1); // 1 for the lacing head (number of laced elements) + } + if (TrackNumber >= 0x80) + SetSize_(GetSize() + 1); - // write Block Head - if (TrackNumber < 0x80) { - *cursor++ = TrackNumber | 0x80; // set the first bit to 1 - } else { - *cursor++ = (TrackNumber >> 8) | 0x40; // set the second bit to 1 - *cursor++ = TrackNumber & 0xFF; - } + // write Block Head + if (TrackNumber < 0x80) { + *cursor++ = TrackNumber | 0x80; // set the first bit to 1 + } else { + *cursor++ = (TrackNumber >> 8) | 0x40; // set the second bit to 1 + *cursor++ = TrackNumber & 0xFF; + } - assert(ParentCluster != nullptr); - const int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode); - const auto b16 = big_int16(ActualTimecode); - b16.Fill(cursor); - cursor += 2; + assert(ParentCluster != nullptr); + const int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode); + const auto b16 = big_int16(ActualTimecode); + b16.Fill(cursor); + cursor += 2; - *cursor = 0; // flags + *cursor = 0; // flags - if (mLacing == LACING_AUTO) { - mLacing = GetBestLacingType(); - } + if (mLacing == LACING_AUTO) { + mLacing = GetBestLacingType(); + } - // invisible flag - if (mInvisible) - *cursor = 0x08; + // invisible flag + if (mInvisible) + *cursor = 0x08; - if (bIsSimple) { - if (bIsKeyframe) - *cursor |= 0x80; - if (bIsDiscardable) - *cursor |= 0x01; - } + if (bIsSimple) { + if (bIsKeyframe) + *cursor |= 0x80; + if (bIsDiscardable) + *cursor |= 0x01; + } - // lacing flag - switch (mLacing) { - case LACING_XIPH: - *cursor++ |= 0x02; - break; - case LACING_EBML: - *cursor++ |= 0x06; - break; - case LACING_FIXED: - *cursor++ |= 0x04; - break; - case LACING_NONE: - break; - default: - assert(0); - } + // lacing flag + switch (mLacing) { + case LACING_XIPH: + *cursor++ |= 0x02; + break; + case LACING_EBML: + *cursor++ |= 0x06; + break; + case LACING_FIXED: + *cursor++ |= 0x04; + break; + case LACING_NONE: + break; + default: + assert(0); + } - output.writeFully(BlockHead, 4 + ((TrackNumber >= 0x80) ? 1 : 0)); + output.writeFully(BlockHead, 4 + ((TrackNumber >= 0x80) ? 1 : 0)); - binary tmpValue; - switch (mLacing) { - case LACING_XIPH: - // number of laces - tmpValue = myBuffers.size()-1; - output.writeFully(&tmpValue, 1); + binary tmpValue; + switch (mLacing) { + case LACING_XIPH: + // number of laces + tmpValue = myBuffers.size()-1; + output.writeFully(&tmpValue, 1); - // set the size of each member in the lace - for (i=0; iSize(); - while (tmpSize >= 0xFF) { - output.writeFully(&tmpValue, 1); - SetSize_(GetSize() + 1); - tmpSize -= 0xFF; - } - tmpValue = static_cast(tmpSize); + // set the size of each member in the lace + for (i=0; iSize(); + while (tmpSize >= 0xFF) { output.writeFully(&tmpValue, 1); SetSize_(GetSize() + 1); + tmpSize -= 0xFF; } - break; - case LACING_EBML: - // number of laces - tmpValue = myBuffers.size()-1; + tmpValue = static_cast(tmpSize); output.writeFully(&tmpValue, 1); - { - int64 _Size; - int _CodedSize; - binary _FinalHead[8]; // 64 bits max coded size + SetSize_(GetSize() + 1); + } + break; + case LACING_EBML: + // number of laces + tmpValue = myBuffers.size()-1; + output.writeFully(&tmpValue, 1); + { + int64 _Size; + int _CodedSize; + binary _FinalHead[8]; // 64 bits max coded size + + _Size = myBuffers[0]->Size(); - _Size = myBuffers[0]->Size(); + _CodedSize = CodedSizeLength(_Size, 0, IsFiniteSize()); - _CodedSize = CodedSizeLength(_Size, 0, IsFiniteSize()); + // first size in the lace is not a signed + CodedValueLength(_Size, _CodedSize, _FinalHead); + output.writeFully(_FinalHead, _CodedSize); + SetSize_(GetSize() + _CodedSize); - // first size in the lace is not a signed - CodedValueLength(_Size, _CodedSize, _FinalHead); + // set the size of each member in the lace + for (i=1; i(myBuffers[i]->Size()) - static_cast(myBuffers[i-1]->Size()); + _CodedSize = CodedSizeLengthSigned(_Size, 0); + CodedValueLengthSigned(_Size, _CodedSize, _FinalHead); output.writeFully(_FinalHead, _CodedSize); SetSize_(GetSize() + _CodedSize); - - // set the size of each member in the lace - for (i=1; i(myBuffers[i]->Size()) - static_cast(myBuffers[i-1]->Size()); - _CodedSize = CodedSizeLengthSigned(_Size, 0); - CodedValueLengthSigned(_Size, _CodedSize, _FinalHead); - output.writeFully(_FinalHead, _CodedSize); - SetSize_(GetSize() + _CodedSize); - } } - break; - case LACING_FIXED: - // number of laces - tmpValue = myBuffers.size()-1; - output.writeFully(&tmpValue, 1); - break; - case LACING_NONE: - break; - default: - assert(0); - } + } + break; + case LACING_FIXED: + // number of laces + tmpValue = myBuffers.size()-1; + output.writeFully(&tmpValue, 1); + break; + case LACING_NONE: + break; + default: + assert(0); + } - // put the data of each frame - for (const auto& myBuf : myBuffers) { - output.writeFully(myBuf->Buffer(), myBuf->Size()); - SetSize_(GetSize() + myBuf->Size()); - } + // put the data of each frame + for (const auto& myBuf : myBuffers) { + output.writeFully(myBuf->Buffer(), myBuf->Size()); + SetSize_(GetSize() + myBuf->Size()); } return GetSize();