Changed getRandomID() to use the full SQLite three-byte range if unable to find a two-byte id in 3 tries

This commit is contained in:
Dan Stillman 2006-06-29 07:03:24 +00:00
parent b495bb6334
commit 35eb1292a5

View File

@ -272,11 +272,11 @@ var Scholar = new function(){
max = 16383; max = 16383;
} }
var tries = 10; // # of tries to find a unique id var tries = 3; // # of tries to find a unique id
do { do {
// If no luck after number of tries, try a larger range // If no luck after number of tries, try a larger range
if (!tries){ if (!tries){
max = max * 2; max = max * 128;
} }
var rnd = Math.floor(Math.random()*max); var rnd = Math.floor(Math.random()*max);
var exists = Scholar.DB.valueQuery(sql + rnd); var exists = Scholar.DB.valueQuery(sql + rnd);