From 71e255cd3115918af581cf98c73b86f34a585272 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 8 Jul 2019 23:29:40 -0400 Subject: [PATCH] packagefs: Remove PackageDataV1 from PackageData. Now that we never access V1 packages in here, we don't need this. This saves *24* bytes off the size of the class, which is extremely significant as not only every PackageFile instance has an instance of this class, but every PackageNode does too; so the savings from this change is probably in the MB. --- .../packagefs/package/PackageData.h | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/src/add-ons/kernel/file_systems/packagefs/package/PackageData.h b/src/add-ons/kernel/file_systems/packagefs/package/PackageData.h index 7968c3ed3b..6b82f717ba 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/PackageData.h +++ b/src/add-ons/kernel/file_systems/packagefs/package/PackageData.h @@ -7,35 +7,27 @@ #include -#include #include typedef BPackageKit::BHPKG::BPackageData PackageDataV2; -typedef BPackageKit::BHPKG::V1::BPackageData PackageDataV1; class PackageData { public: - explicit PackageData(const PackageDataV1& data); explicit PackageData(const PackageDataV2& data); uint8 Version() const { return fVersion; } - const PackageDataV1& DataV1() const; const PackageDataV2& DataV2() const; - uint64 CompressedSize() const; uint64 UncompressedSize() const; bool IsEncodedInline() const; const uint8* InlineData() const; private: - static const size_t kDataSize = sizeof(PackageDataV1) - > sizeof(PackageDataV2) - ? sizeof(PackageDataV1) - : sizeof(PackageDataV2); + static const size_t kDataSize = sizeof(PackageDataV2); private: union { @@ -46,15 +38,6 @@ private: }; -inline -PackageData::PackageData(const PackageDataV1& data) - : - fVersion(1) -{ - memcpy(&fData, &data, sizeof(data)); -} - - inline PackageData::PackageData(const PackageDataV2& data) : @@ -64,13 +47,6 @@ PackageData::PackageData(const PackageDataV2& data) } -inline const PackageDataV1& -PackageData::DataV1() const -{ - return *(PackageDataV1*)&fData; -} - - inline const PackageDataV2& PackageData::DataV2() const { @@ -78,20 +54,9 @@ PackageData::DataV2() const } -inline uint64 -PackageData::CompressedSize() const -{ - if (fVersion == 1) - return DataV1().CompressedSize(); - return DataV2().Size(); -} - - inline uint64 PackageData::UncompressedSize() const { - if (fVersion == 1) - return DataV1().UncompressedSize(); return DataV2().Size(); } @@ -99,8 +64,6 @@ PackageData::UncompressedSize() const inline bool PackageData::IsEncodedInline() const { - if (fVersion == 1) - return DataV1().IsEncodedInline(); return DataV2().IsEncodedInline(); } @@ -108,8 +71,6 @@ PackageData::IsEncodedInline() const inline const uint8* PackageData::InlineData() const { - if (fVersion == 1) - return DataV1().InlineData(); return DataV2().InlineData(); }