From: Rosen Penev Date: Sun, 25 Sep 2022 01:59:45 +0000 (-0700) Subject: remove unnecessary references X-Git-Tag: release-1.7.0~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a560805e37dd4c51d5005bd56dbe1b5de71a3f8c;p=libmatroska remove unnecessary references Pointers are already used. Signed-off-by: Rosen Penev --- diff --git a/src/KaxBlock.cpp b/src/KaxBlock.cpp index 6d6b1b3..62b0947 100644 --- a/src/KaxBlock.cpp +++ b/src/KaxBlock.cpp @@ -797,15 +797,14 @@ bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataB uint64 KaxBlockGroup::GlobalTimecode() const { assert(ParentCluster != nullptr); // impossible otherwise - const auto& MyBlock = *static_cast(this->FindElt(EBML_INFO(KaxBlock))); - return MyBlock.GlobalTimecode(); - + auto MyBlock = static_cast(this->FindElt(EBML_INFO(KaxBlock))); + return MyBlock->GlobalTimecode(); } uint16 KaxBlockGroup::TrackNumber() const { - const auto& MyBlock = *static_cast(this->FindElt(EBML_INFO(KaxBlock))); - return MyBlock.TrackNum(); + auto MyBlock = static_cast(this->FindElt(EBML_INFO(KaxBlock))); + return MyBlock->TrackNum(); } uint64 KaxBlockGroup::ClusterPosition() const @@ -848,8 +847,8 @@ const KaxReferenceBlock & KaxBlockGroup::Reference(unsigned int Index) const void KaxBlockGroup::ReleaseFrames() { - auto& MyBlock = *static_cast(this->FindElt(EBML_INFO(KaxBlock))); - MyBlock.ReleaseFrames(); + auto MyBlock = static_cast(this->FindElt(EBML_INFO(KaxBlock))); + MyBlock->ReleaseFrames(); } void KaxInternalBlock::ReleaseFrames() @@ -869,8 +868,8 @@ void KaxBlockGroup::SetBlockDuration(uint64 TimeLength) { assert(ParentTrack != nullptr); const int64 scale = ParentTrack->GlobalTimecodeScale(); - auto& myDuration = *static_cast(FindFirstElt(EBML_INFO(KaxBlockDuration), true)); - *(static_cast(&myDuration)) = TimeLength / static_cast(scale); + const auto& myDuration = static_cast(FindFirstElt(EBML_INFO(KaxBlockDuration), true)); + *(static_cast(myDuration)) = TimeLength / static_cast(scale); } bool KaxBlockGroup::GetBlockDuration(uint64 &TheTimecode) const diff --git a/src/KaxCluster.cpp b/src/KaxCluster.cpp index a2adaff..b372669 100644 --- a/src/KaxCluster.cpp +++ b/src/KaxCluster.cpp @@ -154,11 +154,11 @@ filepos_t KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bS // SilentTracks handling // check the parent cluster for existing tracks and see if they are contained in this cluster or not if (bSilentTracksUsed) { - const auto& MyTracks = *static_cast(ParentSegment->FindElt(EBML_INFO(KaxTracks))); - for (auto&& Trk : MyTracks) { + auto MyTracks = static_cast(ParentSegment->FindElt(EBML_INFO(KaxTracks))); + for (auto&& Trk : *MyTracks) { if (EbmlId(*Trk) == EBML_ID(KaxTrackEntry)) { - const auto& entry = *static_cast(Trk); - auto tracknum = static_cast(entry.TrackNumber()); + auto entry = static_cast(Trk); + auto tracknum = static_cast(entry->TrackNumber()); auto track = std::find_if(ElementList.begin(), ElementList.end(), [=](EbmlElement *element) { return EbmlId(*element) == EBML_ID(KaxBlockGroup) && static_cast(element)->TrackNumber() == tracknum; }); // the track wasn't found in this cluster @@ -192,11 +192,11 @@ filepos_t KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bS // SilentTracks handling // check the parent cluster for existing tracks and see if they are contained in this cluster or not if (bSilentTracksUsed) { - const auto& MyTracks = *static_cast(ParentSegment->FindElt(EBML_INFO(KaxTracks))); - for (auto&& Trk : MyTracks) { + auto MyTracks = static_cast(ParentSegment->FindElt(EBML_INFO(KaxTracks))); + for (auto&& Trk : *MyTracks) { if (EbmlId(*Trk) == EBML_ID(KaxTrackEntry)) { - const auto& entry = *static_cast(Trk); - auto tracknum = static_cast(entry.TrackNumber()); + auto entry = static_cast(Trk); + auto tracknum = static_cast(entry->TrackNumber()); for (Index = 0; Index(*Blobs[Index]).TrackNum() == tracknum) break; // this track is used diff --git a/src/KaxCuesData.cpp b/src/KaxCuesData.cpp index f528714..e95c180 100644 --- a/src/KaxCuesData.cpp +++ b/src/KaxCuesData.cpp @@ -158,14 +158,14 @@ bool KaxCuePoint::IsSmallerThan(const EbmlElement * Cmp) const assert(EbmlId(*this) == EBML_ID(KaxCuePoint)); assert(EbmlId(*Cmp) == EBML_ID(KaxCuePoint)); - const auto& theCmp = *static_cast(Cmp); + auto theCmp = static_cast(Cmp); // compare timecode auto TimeCodeA = static_cast(FindElt(EBML_INFO(KaxCueTime))); if (TimeCodeA == nullptr) return false; - auto TimeCodeB = static_cast(theCmp.FindElt(EBML_INFO(KaxCueTime))); + auto TimeCodeB = static_cast(theCmp->FindElt(EBML_INFO(KaxCueTime))); if (TimeCodeB == nullptr) return false; @@ -180,7 +180,7 @@ bool KaxCuePoint::IsSmallerThan(const EbmlElement * Cmp) const if (TrackA == nullptr) return false; - auto TrackB = static_cast(theCmp.FindElt(EBML_INFO(KaxCueTrack))); + auto TrackB = static_cast(theCmp->FindElt(EBML_INFO(KaxCueTrack))); if (TrackB == nullptr) return false;