Skip to content

Commit

Permalink
Remove initializers TSPacket and TSHeader
Browse files Browse the repository at this point in the history
The initialization was added in commit 8e70b50 on Jan 10, 2020
to remove warnings from a static code analyzer.
However, the initialization is not needed at all, see comments on lines 52-53 and 61-62, added in
commit 6a4845b on May 1, 2008 and on line 207, added in
commit 4ca584a on Jun 21, 2008 by the original author of this code.
Superfluous initializations are not harmful but in this case it can cost a significant amount of processing resources.
For one full transport stream this can be 4 to 5 Mbyte/second that is needlessly initialized.
  • Loading branch information
kmdewaal committed Jul 8, 2022
1 parent a80e900 commit 9882cac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/mpeg/tspacket.h
Expand Up @@ -173,7 +173,7 @@ class MTV_PUBLIC TSHeader
static constexpr unsigned int kHeaderSize {4};
static const TSHeaderArray kPayloadOnlyHeader;
private:
TSHeaderArray m_tsData {};
TSHeaderArray m_tsData; // Intentionally no initialization
};

static_assert(sizeof(TSHeader) == 4,
Expand Down Expand Up @@ -261,7 +261,7 @@ class MTV_PUBLIC TSPacket : public TSHeader
static constexpr unsigned int k8VSBEmissionSize {208};
static const TSPacket *kNullPacket;
private:
std::array<uint8_t,184> m_tsPayload {};
std::array<uint8_t,184> m_tsPayload; // Intentionally no initialization
};

static_assert(sizeof(TSPacket) == 188,
Expand Down

1 comment on commit 9882cac

@linuxdude42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any initialization was actually occurring, since no object of this type is ever created. This structure only over used when it is overlaid onto a pre-existing buffer in memory.

Please sign in to comment.