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
|
||||
* or return the default value
|
||||
* Get the value for a given key if it exists, or return the default value.
|
||||
*
|
||||
* @public
|
||||
* @memberof AnnotationStorage
|
||||
@ -43,11 +42,8 @@ class AnnotationStorage {
|
||||
* @returns {Object}
|
||||
*/
|
||||
getValue(key, defaultValue) {
|
||||
if (this._storage.has(key)) {
|
||||
return this._storage.get(key);
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
const obj = this._storage.get(key);
|
||||
return obj !== undefined ? obj : defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user