mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 11:20:09 +00:00 
			
		
		
		
	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:
		
							parent
							
								
									440eedbb36
								
							
						
					
					
						commit
						32211cbbe3
					
				| @ -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...
 | ||||
|  | ||||
| @ -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){ | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user