ProfileCompilationInfo info;
for (const std::unique_ptr<const DexFile>& dex_file : dex_files) {
- std::cout << std::string(dex_file->GetLocation());
- profile_info_.AddData(dex_file->GetLocation(), dex_file->GetLocationChecksum(), 1);
- profile_info_.AddData(dex_file->GetLocation(), dex_file->GetLocationChecksum(), 2);
+ std::string key = ProfileCompilationInfo::GetProfileDexFileKey(dex_file->GetLocation());
+ profile_info_.AddData(key, dex_file->GetLocationChecksum(), 1);
+ profile_info_.AddData(key, dex_file->GetLocationChecksum(), 2);
}
return &profile_info_;
}
// Note: this is OK because we don't store profiles of different apps into the same file.
// Apps with split apks don't cause trouble because each split has a different name and will not
// collide with other entries.
-static std::string GetProfileDexFileKey(const std::string& dex_location) {
+std::string ProfileCompilationInfo::GetProfileDexFileKey(const std::string& dex_location) {
DCHECK(!dex_location.empty());
size_t last_sep_index = dex_location.find_last_of('/');
if (last_sep_index == std::string::npos) {
return dex_location;
} else {
- return dex_location.substr(last_sep_index);
+ DCHECK(last_sep_index < dex_location.size());
+ return dex_location.substr(last_sep_index + 1);
}
}
// For testing purposes.
bool Equals(ProfileCompilationInfo& other);
+ // Exposed for testing purpose.
+ static std::string GetProfileDexFileKey(const std::string& dex_location);
private:
bool AddData(const std::string& dex_location, uint32_t checksum, uint16_t method_idx);