Bug 1116600 - Change RegExp constructor to RegExp literal. r=mak
authoranirudhgp <anirudh.gp@gmail.com>
Thu, 15 Jan 2015 06:25:00 -0500
changeset 223980 fadf6d3cc68c867e7197f83be4e1ebad34dfb128
parent 223979 87b85873dd84b00a129d7d288c08a0104043f9a5
child 223981 d10a044ab2dc519c3b431f6d612e6f856f4c2cb3
push id10842
push userryanvm@gmail.com
push dateThu, 15 Jan 2015 20:05:55 +0000
treeherderfx-team@d10a044ab2dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1116600
milestone38.0a1
Bug 1116600 - Change RegExp constructor to RegExp literal. r=mak
toolkit/components/places/PlacesBackups.jsm
--- a/toolkit/components/places/PlacesBackups.jsm
+++ b/toolkit/components/places/PlacesBackups.jsm
@@ -24,17 +24,17 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
   "resource://gre/modules/osfile.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "localFileCtor",
   () => Components.Constructor("@mozilla.org/file/local;1",
                                "nsILocalFile", "initWithPath"));
 
 XPCOMUtils.defineLazyGetter(this, "filenamesRegex",
-  () => new RegExp("^bookmarks-([0-9\-]+)(?:_([0-9]+)){0,1}(?:_([a-z0-9=\+\-]{24})){0,1}\.(json(lz4)?)$", "i")
+  () => /^bookmarks-([0-9-]+)(?:_([0-9]+)){0,1}(?:_([a-z0-9=+-]{24})){0,1}\.(json(lz4)?)$/i
 );
 
 /**
  * Appends meta-data information to a given filename.
  */
 function appendMetaDataToFilename(aFilename, aMetaData) {
   let matches = aFilename.match(filenamesRegex);
   return "bookmarks-" + matches[1] +
@@ -260,34 +260,34 @@ this.PlacesBackups = {
    * @returns nsIFile backup file
    */
   getMostRecent: function PB_getMostRecent() {
     Deprecated.warning(
       "PlacesBackups.getMostRecent is deprecated and will be removed in a future version",
       "https://bugzilla.mozilla.org/show_bug.cgi?id=859695");
 
     for (let i = 0; i < this._entries.length; i++) {
-      let rx = new RegExp("\.json(lz4)?$");
+      let rx = /\.json(lz4)?$/;
       if (this._entries[i].leafName.match(rx))
         return this._entries[i];
     }
     return null;
   },
 
    /**
     * Get the most recent backup file.
     *
     * @return {Promise}
     * @result the path to the file.
     */
    getMostRecentBackup: function PB_getMostRecentBackup() {
      return Task.spawn(function* () {
        let entries = yield this.getBackupFiles();
        for (let entry of entries) {
-         let rx = new RegExp("\.json(lz4)?$");
+         let rx = /\.json(lz4)?$/;
          if (OS.Path.basename(entry).match(rx)) {
            return entry;
          }
        }
        return null;
     }.bind(this));
   },