]> granicus.if.org Git - libmatroska/commitdiff
remove unnecessary references
authorRosen Penev <rosenp@gmail.com>
Sun, 25 Sep 2022 01:59:45 +0000 (18:59 -0700)
committerRosen Penev <rosenp@gmail.com>
Mon, 26 Sep 2022 20:49:07 +0000 (13:49 -0700)
Pointers are already used.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
src/KaxBlock.cpp
src/KaxCluster.cpp
src/KaxCuesData.cpp

index 6d6b1b32fdfe2c6f3dc51eac8d39cfb7cfef6ea4..62b0947878845bf5188eb08039bc39b65dd6bf51 100644 (file)
@@ -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<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
-  return MyBlock.GlobalTimecode();
-
+  auto MyBlock = static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
+  return MyBlock->GlobalTimecode();
 }
 
 uint16 KaxBlockGroup::TrackNumber() const
 {
-  const auto& MyBlock = *static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
-  return MyBlock.TrackNum();
+  auto MyBlock = static_cast<KaxBlock *>(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<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
-  MyBlock.ReleaseFrames();
+  auto MyBlock = static_cast<KaxBlock *>(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<KaxBlockDuration *>(FindFirstElt(EBML_INFO(KaxBlockDuration), true));
-  *(static_cast<EbmlUInteger *>(&myDuration)) = TimeLength / static_cast<uint64>(scale);
+  const auto& myDuration = static_cast<KaxBlockDuration *>(FindFirstElt(EBML_INFO(KaxBlockDuration), true));
+  *(static_cast<EbmlUInteger *>(myDuration)) = TimeLength / static_cast<uint64>(scale);
 }
 
 bool KaxBlockGroup::GetBlockDuration(uint64 &TheTimecode) const
index a2adaff4750f9b330fbfaa10a262d3786ae0a0cf..b37266902d53e622717a1b52ef14e7a499dc3c0f 100644 (file)
@@ -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<KaxTracks *>(ParentSegment->FindElt(EBML_INFO(KaxTracks)));
-      for (auto&& Trk : MyTracks) {
+      auto MyTracks = static_cast<KaxTracks *>(ParentSegment->FindElt(EBML_INFO(KaxTracks)));
+      for (auto&& Trk : *MyTracks) {
         if (EbmlId(*Trk) == EBML_ID(KaxTrackEntry)) {
-          const auto& entry = *static_cast<KaxTrackEntry *>(Trk);
-          auto tracknum = static_cast<uint32>(entry.TrackNumber());
+          auto entry = static_cast<KaxTrackEntry *>(Trk);
+          auto tracknum = static_cast<uint32>(entry->TrackNumber());
           auto track = std::find_if(ElementList.begin(), ElementList.end(), [=](EbmlElement *element)
               { return EbmlId(*element) == EBML_ID(KaxBlockGroup) && static_cast<KaxBlockGroup *>(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<KaxTracks *>(ParentSegment->FindElt(EBML_INFO(KaxTracks)));
-      for (auto&& Trk : MyTracks) {
+      auto MyTracks = static_cast<KaxTracks *>(ParentSegment->FindElt(EBML_INFO(KaxTracks)));
+      for (auto&& Trk : *MyTracks) {
         if (EbmlId(*Trk) == EBML_ID(KaxTrackEntry)) {
-          const auto& entry = *static_cast<KaxTrackEntry *>(Trk);
-          auto tracknum = static_cast<uint32>(entry.TrackNumber());
+          auto entry = static_cast<KaxTrackEntry *>(Trk);
+          auto tracknum = static_cast<uint32>(entry->TrackNumber());
           for (Index = 0; Index<Blobs.size(); Index++) {
             if (static_cast<KaxInternalBlock&>(*Blobs[Index]).TrackNum() == tracknum)
               break; // this track is used
index f5287141707d50e561bc807b9b95331e4590c2bc..e95c180bb47a73e321b4aba9c43a900cd295756b 100644 (file)
@@ -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<const KaxCuePoint *>(Cmp);
+  auto theCmp = static_cast<const KaxCuePoint *>(Cmp);
 
   // compare timecode
   auto TimeCodeA = static_cast<const KaxCueTime *>(FindElt(EBML_INFO(KaxCueTime)));
   if (TimeCodeA == nullptr)
     return false;
 
-  auto TimeCodeB = static_cast<const KaxCueTime *>(theCmp.FindElt(EBML_INFO(KaxCueTime)));
+  auto TimeCodeB = static_cast<const KaxCueTime *>(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<const KaxCueTrack *>(theCmp.FindElt(EBML_INFO(KaxCueTrack)));
+  auto TrackB = static_cast<const KaxCueTrack *>(theCmp->FindElt(EBML_INFO(KaxCueTrack)));
   if (TrackB == nullptr)
     return false;