From: Rosen Penev Date: Sat, 15 Oct 2022 16:53:24 +0000 (-0700) Subject: clang-tidy: remove non const operator X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ae74578e55469fa2654287e31346149177235b7;p=libmatroska clang-tidy: remove non const operator Found with readability-make-member-function-const Signed-off-by: Rosen Penev --- diff --git a/matroska/KaxBlock.h b/matroska/KaxBlock.h index 7be8d09..6021d32 100644 --- a/matroska/KaxBlock.h +++ b/matroska/KaxBlock.h @@ -327,10 +327,10 @@ public: delete Block.group; } - operator KaxBlockGroup &(); + operator KaxBlockGroup &() const; operator const KaxBlockGroup &() const; - operator KaxSimpleBlock &(); - operator KaxInternalBlock &(); + operator KaxSimpleBlock &() const; + operator KaxInternalBlock &() const; operator const KaxInternalBlock &() const; void SetBlockGroup( KaxBlockGroup &BlockRef ); diff --git a/src/KaxBlock.cpp b/src/KaxBlock.cpp index 90fb4f3..0adc48e 100644 --- a/src/KaxBlock.cpp +++ b/src/KaxBlock.cpp @@ -932,7 +932,7 @@ std::int64_t KaxInternalBlock::GetFrameSize(std::size_t FrameNumber) return _Result; } -KaxBlockBlob::operator KaxBlockGroup &() +KaxBlockBlob::operator KaxBlockGroup &() const { assert(!bUseSimpleBlock); assert(Block.group); @@ -946,7 +946,7 @@ KaxBlockBlob::operator const KaxBlockGroup &() const return *Block.group; } -KaxBlockBlob::operator KaxInternalBlock &() +KaxBlockBlob::operator KaxInternalBlock &() const { assert(Block.group); if (bUseSimpleBlock) @@ -962,7 +962,7 @@ KaxBlockBlob::operator const KaxInternalBlock &() const return *Block.group; } -KaxBlockBlob::operator KaxSimpleBlock &() +KaxBlockBlob::operator KaxSimpleBlock &() const { assert(bUseSimpleBlock); assert(Block.simpleblock); @@ -985,8 +985,8 @@ bool KaxBlockBlob::AddFrameAuto(const KaxTrackEntry & track, std::uint64_t timec Block.simpleblock->SetDiscardable(false); } else { Block.simpleblock->SetKeyframe(false); - if ((!ForwBlock || static_cast(*ForwBlock).GlobalTimecode() <= timecode) && - (!PastBlock || static_cast(*PastBlock).GlobalTimecode() <= timecode)) + if ((!ForwBlock || static_cast(*ForwBlock).GlobalTimecode() <= timecode) && + (!PastBlock || static_cast(*PastBlock).GlobalTimecode() <= timecode)) Block.simpleblock->SetDiscardable(false); else Block.simpleblock->SetDiscardable(true); diff --git a/src/KaxBlockData.cpp b/src/KaxBlockData.cpp index 63c2d4b..e7f4c7c 100644 --- a/src/KaxBlockData.cpp +++ b/src/KaxBlockData.cpp @@ -76,7 +76,7 @@ filepos_t KaxReferenceBlock::UpdateSize(bool bSaveDefault, bool bForceRender) assert(RefdBlock); assert(ParentBlock); - const auto &block = static_cast(*RefdBlock); + auto &block = static_cast(*RefdBlock); SetValue(static_cast(block.GlobalTimecode()) - static_cast(ParentBlock->GlobalTimecode()) / static_cast(ParentBlock->GlobalTimecodeScale())); } return EbmlSInteger::UpdateSize(bSaveDefault, bForceRender); diff --git a/src/KaxCues.cpp b/src/KaxCues.cpp index 8677dc6..f14157a 100644 --- a/src/KaxCues.cpp +++ b/src/KaxCues.cpp @@ -93,7 +93,7 @@ void KaxCues::PositionSet(const KaxBlockGroup & BlockRef) // look for the element in the temporary references auto it = std::find_if(myTempReferences.begin(), myTempReferences.end(), [&](const KaxBlockBlob *myTempReference) - { const auto &refTmp = static_cast(*myTempReference); + { auto& refTmp = static_cast(*myTempReference); return refTmp.GlobalTimecode() == BlockRef.GlobalTimecode() && refTmp.TrackNum() == BlockRef.TrackNumber(); }); diff --git a/src/KaxCuesData.cpp b/src/KaxCuesData.cpp index d69f105..7cf768e 100644 --- a/src/KaxCuesData.cpp +++ b/src/KaxCuesData.cpp @@ -78,11 +78,11 @@ void KaxCuePoint::PositionSet(const KaxBlockGroup & BlockReference, std::uint64_ void KaxCuePoint::PositionSet(const KaxBlockBlob & BlobReference, std::uint64_t GlobalTimecodeScale) { - const auto &BlockReference = static_cast(BlobReference); + auto &BlockReference = static_cast(BlobReference); const KaxBlockGroup *BlockGroupPointer = nullptr; if (!BlobReference.IsSimpleBlock()) { - const auto &BlockGroup = static_cast(BlobReference); + auto &BlockGroup = static_cast(BlobReference); BlockGroupPointer = &BlockGroup; } PositionSet(BlockReference, BlockGroupPointer, GlobalTimecodeScale); @@ -133,8 +133,8 @@ void KaxCuePoint::PositionSet(const KaxInternalBlock & BlockReference, const Kax */ void KaxCueReference::AddReference(const KaxBlockBlob & BlockReference, std::uint64_t GlobalTimecodeScale) { - const auto& theBlock = static_cast(BlockReference); - auto & NewTime = GetChild(*this); + auto& theBlock = static_cast(BlockReference); + auto& NewTime = GetChild(*this); *static_cast(&NewTime) = theBlock.GlobalTimecode() / GlobalTimecodeScale; auto & TheClustPos = GetChild(*this);