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.
This commit is contained in:
parent
ed9a502a9a
commit
71e255cd31
@ -7,35 +7,27 @@
|
||||
|
||||
|
||||
#include <package/hpkg/PackageData.h>
|
||||
#include <package/hpkg/v1/PackageData.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user