Revert "Cache DexFile begin and size"
This reverts commit 689caf046cb99efda4462183eeaacb11a6119adb.
Reason for revert: Did not fix regression caused by prior CL.
Change-Id: I8a01bacfa98539d2980095c445cd580d73e39975
diff --git a/libdexfile/dex/dex_file.cc b/libdexfile/dex/dex_file.cc
index 47a6c1b..c2b478a 100644
--- a/libdexfile/dex/dex_file.cc
+++ b/libdexfile/dex/dex_file.cc
@@ -99,11 +99,6 @@
const OatDexFile* oat_dex_file,
bool is_compact_dex)
: main_section_(std::move(main_section)),
- main_begin_(main_section_->Begin()),
- main_size_(main_section_->Size()),
- data_section_(std::move(data_section)),
- data_begin_(data_section_->Begin()),
- data_size_(data_section_->Size()),
location_(location),
location_checksum_(location_checksum),
header_(reinterpret_cast<const Header*>(main_section_->Begin())),
@@ -132,6 +127,8 @@
// any of the sections via a pointer.
CHECK_ALIGNED(main_section_->Begin(), alignof(Header));
+ data_section_ = std::move(data_section);
+
InitializeSectionsFromMapList();
}
@@ -141,12 +138,6 @@
const OatDexFile* oat_dex_file,
bool is_compact_dex)
: main_section_(std::move(main_section)),
- main_begin_(main_section_->Begin()),
- main_size_(main_section_->Size()),
- data_section_(std::make_unique<NonOwningDexFileContainer>(main_section_->Begin(),
- main_section_->Size())),
- data_begin_(data_section_->Begin()),
- data_size_(data_section_->Size()),
location_(location),
location_checksum_(location_checksum),
header_(reinterpret_cast<const Header*>(main_section_->Begin())),
@@ -175,6 +166,9 @@
// any of the sections via a pointer.
CHECK_ALIGNED(main_section_->Begin(), alignof(Header));
+ data_section_ = std::make_unique<NonOwningDexFileContainer>(main_section_->Begin(),
+ main_section_->Size());
+
InitializeSectionsFromMapList();
}
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index 714e42c..c94c786 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -966,19 +966,19 @@
bool DisableWrite() const;
const uint8_t* Begin() const {
- return main_begin_;
+ return main_section_->Begin();
}
size_t Size() const {
- return main_size_;
+ return main_section_->Size();
}
const uint8_t* DataBegin() const {
- return data_begin_;
+ return data_section_->Begin();
}
size_t DataSize() const {
- return data_size_;
+ return data_section_->Size();
}
template <typename T>
@@ -1089,14 +1089,10 @@
void InitializeSectionsFromMapList();
// The container for the header and fixed portions.
- const std::unique_ptr<DexFileContainer> main_section_;
- const uint8_t* const main_begin_;
- const size_t main_size_;
+ std::unique_ptr<DexFileContainer> main_section_;
- // The container for the data section.
- const std::unique_ptr<DexFileContainer> data_section_;
- const uint8_t* const data_begin_;
- const size_t data_size_;
+ // The container for the data section
+ std::unique_ptr<DexFileContainer> data_section_;
// Typically the dex file name when available, alternatively some identifying string.
//