Simplify the data lookup in the AnnotationStorage.getValue
method
Rather than first checking if data exists before fetching it from storage, we can simply do the lookup directly and then check its value. Note that this follows the same pattern as utilized in the `AnnotationStorage.setValue` method.
This commit is contained in:
parent
a0e584eeb2
commit
b326432895
@ -33,8 +33,7 @@ class AnnotationStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value for a given key if it exists
|
* Get the value for a given key if it exists, or return the default value.
|
||||||
* or return the default value
|
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
* @memberof AnnotationStorage
|
* @memberof AnnotationStorage
|
||||||
@ -43,11 +42,8 @@ class AnnotationStorage {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
getValue(key, defaultValue) {
|
getValue(key, defaultValue) {
|
||||||
if (this._storage.has(key)) {
|
const obj = this._storage.get(key);
|
||||||
return this._storage.get(key);
|
return obj !== undefined ? obj : defaultValue;
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user