Skip to content

Commit

Permalink
Merge pull request mozilla#9849 from Snuffleupagus/rm-cloneObj
Browse files Browse the repository at this point in the history
Replace the `cloneObj` helper function, in the viewer, with native `Object.assign` (PR 9795 follow-up)
  • Loading branch information
timvandermeij authored Jun 27, 2018
2 parents 23545ff + 788ffba commit 4217e0e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
5 changes: 2 additions & 3 deletions web/pdf_document_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*/

import {
cloneObj, getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation,
NullL10n
getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation, NullL10n
} from './ui_utils';
import { createPromiseCapability } from 'pdfjs-lib';

Expand Down Expand Up @@ -161,7 +160,7 @@ class PDFDocumentProperties {
if (fileSize === this.fieldData['fileSize']) {
return; // The fileSize has already been correctly set.
}
let data = cloneObj(this.fieldData);
let data = Object.assign(Object.create(null), this.fieldData);
data['fileSize'] = fileSize;

freezeFieldData(data);
Expand Down
4 changes: 2 additions & 2 deletions web/pdf_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import {
cloneObj, isValidRotation, parseQueryString, waitOnEventOrTimeout
isValidRotation, parseQueryString, waitOnEventOrTimeout
} from './ui_utils';
import { getGlobalEventBus } from './dom_events';

Expand Down Expand Up @@ -303,7 +303,7 @@ class PDFHistory {
}
let position = this._position;
if (temporary) {
position = cloneObj(this._position);
position = Object.assign(Object.create(null), this._position);
position.temporary = true;
}

Expand Down
6 changes: 2 additions & 4 deletions web/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* limitations under the License.
*/

import { cloneObj } from './ui_utils';

let defaultPreferences = null;
function getDefaultPreferences() {
if (!defaultPreferences) {
Expand Down Expand Up @@ -60,7 +58,7 @@ class BasePreferences {
configurable: false,
});

this.prefs = cloneObj(defaults);
this.prefs = Object.assign(Object.create(null), defaults);
return this._readFromStorage(defaults);
}).then((prefObj) => {
if (prefObj) {
Expand Down Expand Up @@ -96,7 +94,7 @@ class BasePreferences {
*/
reset() {
return this._initializedPromise.then(() => {
this.prefs = cloneObj(this.defaults);
this.prefs = Object.assign(Object.create(null), this.defaults);
return this._writeToStorage(this.defaults);
});
}
Expand Down
11 changes: 0 additions & 11 deletions web/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,16 +611,6 @@ function isPortraitOrientation(size) {
return size.width <= size.height;
}

function cloneObj(obj) {
let result = Object.create(null);
for (let i in obj) {
if (Object.prototype.hasOwnProperty.call(obj, i)) {
result[i] = obj[i];
}
}
return result;
}

const WaitOnType = {
EVENT: 'event',
TIMEOUT: 'timeout',
Expand Down Expand Up @@ -842,7 +832,6 @@ export {
VERTICAL_PADDING,
isValidRotation,
isPortraitOrientation,
cloneObj,
PresentationModeState,
RendererType,
TextLayerMode,
Expand Down

0 comments on commit 4217e0e

Please sign in to comment.