slight improvement in nextImageInOrder/prevImageInOrder actions... (started before the prev commit)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-07 04:56:19 +03:00
parent 440eedbb36
commit 32211cbbe3
3 changed files with 49 additions and 6 deletions

View File

@ -354,7 +354,7 @@ module.ImagesPrototype = {
return this
},
filter: function(func){
var res = this.constructor()
var res = new this.constructor()
var i = 0
for(var key in this){
// reject non images...

View File

@ -14,6 +14,8 @@ console.log('>>> objects')
/*********************************************************************/
// XXX BUG: if the constructor is called from it's instance this will
// return the instance and not a new object...
var makeConstructor =
module.makeConstructor =
function makeConstructor(name, a, b){

View File

@ -367,7 +367,8 @@ actions.Actions({
lastGlobalImage: ['Navigate/Last globally image',
function(){ this.lastImage(true) }],
// XXX skip unloaded images...
// XXX skip unloaded images... (groups?)
// XXX the next two are almost identical...
prevImage: ['Navigate/Previous image',
function(a){
// keep track of traverse direction...
@ -399,11 +400,50 @@ actions.Actions({
}
}],
// XXX skip unloaded images...
// XXX skip unloaded images... (groups?)
// XXX the next two are almost identical...
prevImageInOrder: ['Navigate/Previous image in order',
function(){ this.prevImage(this.data.getImages(this.data.order)) }],
function(){
// NOTE: this used to be algorithmically substantially slower
// than the code below but after .makeSparseImages(..)
// got updated the difference is far less...
// ...since I've already spent the time to write and
// debug the long version and it gives a small advantage
// I'll keep it for now...
// (~15-20% @ 10K images, e.g 50ms vs 80ms on average)
//this.prevImage(this.data.getImages('loaded'))
var c = {}
// get prev images for each ribbon...
for(var r in this.data.ribbons){
var i = this.data.getImageOrder('prev', r)
if(i >= 0){
c[i] = r
}
}
this.prevImage(c[Math.max.apply(null, Object.keys(c))])
}],
nextImageInOrder: ['Navigate/Next image in order',
function(){ this.nextImage(this.data.getImages(this.data.order)) }],
function(){
// NOTE: this used to be algorithmically substantially slower
// than the code below but after .makeSparseImages(..)
// got updated the difference is far less...
// ...since I've already spent the time to write and
// debug the long version and it gives a small advantage
// I'll keep it for now...
// (~15-20% @ 10K images)
//this.nextImage(this.data.getImages('loaded'))
var c = {}
// get next images for each ribbon...
for(var r in this.data.ribbons){
var i = this.data.getImageOrder('next', r)
if(i >= 0){
c[i] = r
}
}
this.nextImage(c[Math.min.apply(null, Object.keys(c))])
}],
// XXX should these be here???
prevTagged: ['Navigate/Previous image tagged with tag',
@ -3576,7 +3616,8 @@ var FileSystemLoaderActions = actions.Actions({
// NOTE: all ribbon gids will change here...
var cur = that.data.current
// XXX this does not seem to work...
that.data = new_data.join(that.data)
//that.data = new_data.join(that.data)
that.data = new_data.join('top', that.data)
that.data.current = cur
that.images.join(new_images)