[profiler] Avoid double lookup in script map
Use the result of scripts.find() instead of using operator[] when looking up scripts. This avoids an ugly const_cast, and avoids doing the lookup twice. Change-Id: I7c1a6be28928e2e3d928c389328be8785be3cff7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3056989 Auto-Submit: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Reviewed-by: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/master@{#75974}
This commit is contained in:
parent
da3698523a
commit
f298b11b5e
@ -219,13 +219,10 @@ v8::AllocationProfile::Node* SamplingHeapProfiler::TranslateAllocationNode(
|
||||
int column = v8::AllocationProfile::kNoColumnNumberInfo;
|
||||
std::vector<v8::AllocationProfile::Allocation> allocations;
|
||||
allocations.reserve(node->allocations_.size());
|
||||
if (node->script_id_ != v8::UnboundScript::kNoScriptId &&
|
||||
scripts.find(node->script_id_) != scripts.end()) {
|
||||
// Cannot use std::map<T>::at because it is not available on android.
|
||||
auto non_const_scripts =
|
||||
const_cast<std::map<int, Handle<Script>>&>(scripts);
|
||||
Handle<Script> script = non_const_scripts[node->script_id_];
|
||||
if (!script.is_null()) {
|
||||
if (node->script_id_ != v8::UnboundScript::kNoScriptId) {
|
||||
auto script_iterator = scripts.find(node->script_id_);
|
||||
if (script_iterator != scripts.end()) {
|
||||
Handle<Script> script = script_iterator->second;
|
||||
if (script->name().IsName()) {
|
||||
Name name = Name::cast(script->name());
|
||||
script_name = ToApiHandle<v8::String>(
|
||||
|
Loading…
Reference in New Issue
Block a user