refactor: remove redundant map lookups in browser/api/menu.ts (#48731)
perf: avoid double map lookup in Menu.prototype._shouldCommandIdWorkWhenHidden perf: avoid double map lookup in Menu.prototype._isCommandIdVisible perf: avoid double map lookup in Menu.prototype._shouldRegisterAcceleratorForCommandId perf: avoid double map lookup in Menu.prototype._getSharingItemForCommandId Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
0c0376637c
commit
f404955dc8
1 changed files with 4 additions and 4 deletions
|
|
@ -46,11 +46,11 @@ Menu.prototype._isCommandIdEnabled = function (id) {
|
|||
};
|
||||
|
||||
Menu.prototype._shouldCommandIdWorkWhenHidden = function (id) {
|
||||
return this.commandsMap[id] ? !!this.commandsMap[id].acceleratorWorksWhenHidden : false;
|
||||
return this.commandsMap[id]?.acceleratorWorksWhenHidden ?? false;
|
||||
};
|
||||
|
||||
Menu.prototype._isCommandIdVisible = function (id) {
|
||||
return this.commandsMap[id] ? this.commandsMap[id].visible : false;
|
||||
return this.commandsMap[id]?.visible ?? false;
|
||||
};
|
||||
|
||||
Menu.prototype._getAcceleratorForCommandId = function (id, useDefaultAccelerator) {
|
||||
|
|
@ -61,12 +61,12 @@ Menu.prototype._getAcceleratorForCommandId = function (id, useDefaultAccelerator
|
|||
};
|
||||
|
||||
Menu.prototype._shouldRegisterAcceleratorForCommandId = function (id) {
|
||||
return this.commandsMap[id] ? this.commandsMap[id].registerAccelerator : false;
|
||||
return this.commandsMap[id]?.registerAccelerator ?? false;
|
||||
};
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
Menu.prototype._getSharingItemForCommandId = function (id) {
|
||||
return this.commandsMap[id] ? this.commandsMap[id].sharingItem : null;
|
||||
return this.commandsMap[id]?.sharingItem ?? null;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue