From a4cb8608da2651b386d7c8539ffedbe803991f07 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 24 Oct 2010 23:55:50 +0000 Subject: [PATCH] remove ZU.probability --- chrome/content/zotero/xpcom/debug.js | 2 +- chrome/content/zotero/xpcom/utilities.js | 13 ------------- chrome/content/zotero/xpcom/zotero.js | 2 +- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/xpcom/debug.js b/chrome/content/zotero/xpcom/debug.js index 47abac9af..ebeca3479 100644 --- a/chrome/content/zotero/xpcom/debug.js +++ b/chrome/content/zotero/xpcom/debug.js @@ -80,7 +80,7 @@ Zotero.Debug = new function () { dump('zotero(' + level + ')' + (_time ? deltaStr : '') + ': ' + message + "\n\n"); } if (_store) { - if (Zotero.Utilities.prototype.probability(1000)) { + if (Math.random() < 1/1000) { // Remove initial lines if over limit var overage = this.count() - Zotero.Prefs.get('debug.store.limit'); if (overage > 0) { diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 2a716fe8e..aeddfe4ff 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -406,19 +406,6 @@ Zotero.Utilities.prototype.rand = function (min, max) { } -/** - * Return true according to a given probability - * - * @param {Integer} x Will return true every x times on average - * @return {Boolean} On average, TRUE every x times - * the function is called - */ -Zotero.Utilities.prototype.probability = function (x) { - return this.rand(1, x) == this.rand(1, x); -} - - - /** * Determine the necessary data type for SQLite parameter binding * diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 186e329c7..594038099 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1377,7 +1377,7 @@ var Zotero = new function(){ // DEBUG: this might not need to be permanent Zotero.Relations.purge(); - if (!skipStoragePurge && Zotero.Utilities.prototype.probability(10)) { + if (!skipStoragePurge && Math.random() < 1/10) { Zotero.Sync.Storage.purgeDeletedStorageFiles('zfs'); Zotero.Sync.Storage.purgeDeletedStorageFiles('webdav'); }