perf: avoid redundant map lookup in NativeImage::GetHICON() (#39058)
perf: avoid double map lookup in NativeImage::GetHICON()
This commit is contained in:
parent
da3475998f
commit
a8622aed7b
1 changed files with 8 additions and 6 deletions
|
@ -202,21 +202,23 @@ bool NativeImage::TryConvertNativeImage(v8::Isolate* isolate,
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
#if BUILDFLAG(IS_WIN)
|
||||||
HICON NativeImage::GetHICON(int size) {
|
HICON NativeImage::GetHICON(int size) {
|
||||||
auto iter = hicons_.find(size);
|
if (auto iter = hicons_.find(size); iter != hicons_.end())
|
||||||
if (iter != hicons_.end())
|
|
||||||
return iter->second.get();
|
return iter->second.get();
|
||||||
|
|
||||||
// First try loading the icon with specified size.
|
// First try loading the icon with specified size.
|
||||||
if (!hicon_path_.empty()) {
|
if (!hicon_path_.empty()) {
|
||||||
hicons_[size] = ReadICOFromPath(size, hicon_path_);
|
auto& hicon = hicons_[size];
|
||||||
return hicons_[size].get();
|
hicon = ReadICOFromPath(size, hicon_path_);
|
||||||
|
return hicon.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then convert the image to ICO.
|
// Then convert the image to ICO.
|
||||||
if (image_.IsEmpty())
|
if (image_.IsEmpty())
|
||||||
return NULL;
|
return NULL;
|
||||||
hicons_[size] = IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap());
|
|
||||||
return hicons_[size].get();
|
auto& hicon = hicons_[size];
|
||||||
|
hicon = IconUtil::CreateHICONFromSkBitmap(image_.AsBitmap());
|
||||||
|
return hicon.get();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue