зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1101817 - Part 3: Remove WeakMap.prototype.clear usages from Addons SDK. r=mossop
--HG-- extra : rebase_source : 45c1935d03eb07b24a72208397a3c35261f7d1aa
This commit is contained in:
Родитель
f49f16b651
Коммит
7f18c4084f
|
@ -13,16 +13,21 @@ const { Cu } = require("chrome");
|
|||
function makeGetterFor(Type) {
|
||||
let cache = new WeakMap();
|
||||
|
||||
return function getFor(target) {
|
||||
if (!cache.has(target))
|
||||
cache.set(target, new Type());
|
||||
return {
|
||||
getFor(target) {
|
||||
if (!cache.has(target))
|
||||
cache.set(target, new Type());
|
||||
|
||||
return cache.get(target);
|
||||
return cache.get(target);
|
||||
},
|
||||
clearFor(target) {
|
||||
return cache.delete(target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var getLookupFor = makeGetterFor(WeakMap);
|
||||
var getRefsFor = makeGetterFor(Set);
|
||||
var {getFor: getLookupFor, clearFor: clearLookupFor} = makeGetterFor(WeakMap);
|
||||
var {getFor: getRefsFor, clearFor: clearRefsFor} = makeGetterFor(Set);
|
||||
|
||||
function add(target, value) {
|
||||
if (has(target, value))
|
||||
|
@ -44,8 +49,8 @@ function has(target, value) {
|
|||
exports.has = has;
|
||||
|
||||
function clear(target) {
|
||||
getLookupFor(target).clear();
|
||||
getRefsFor(target).clear();
|
||||
clearLookupFor(target);
|
||||
clearRefsFor(target);
|
||||
}
|
||||
exports.clear = clear;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче