mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
optimized out a braindead pice of code (wonder who wrote it) +40% speed...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c187f40653
commit
fead30ce3d
@ -741,10 +741,11 @@ var TagsPrototype = {
|
||||
tags = this.normalize(tags instanceof Array ? tags : [tags])
|
||||
var index = this.__index = this.__index || {}
|
||||
|
||||
value.forEach(function(value){
|
||||
tags
|
||||
.forEach(function(tag){
|
||||
(index[tag] = index[tag] || new Set()).add(value) }) })
|
||||
tags
|
||||
.forEach(function(tag){
|
||||
index[tag] = tag in index ?
|
||||
index[tag].unite(value)
|
||||
: new Set(value) })
|
||||
|
||||
return this
|
||||
},
|
||||
@ -753,26 +754,30 @@ var TagsPrototype = {
|
||||
untag: function(tags, value){
|
||||
var that = this
|
||||
var index = this.__index = this.__index || {}
|
||||
|
||||
value = value instanceof Array ? value : [value]
|
||||
tags = this.normalize(tags instanceof Array ? tags : [tags])
|
||||
|
||||
this
|
||||
.normalize(tags instanceof Array ? tags : [tags])
|
||||
// resolve/match tags...
|
||||
.map(function(tag){
|
||||
return /\*/.test(tag) ?
|
||||
// resolve tag patterns...
|
||||
that.match(tag)
|
||||
: tag })
|
||||
.flat()
|
||||
// do the untagging...
|
||||
.forEach(function(tag){
|
||||
var s = (index[tag] || new Set()).subtract(value)
|
||||
|
||||
value.forEach(function(value){
|
||||
tags
|
||||
.forEach(function(tag){
|
||||
var s = index[tag] || new Set()
|
||||
s.delete(value)
|
||||
// remove empty sets...
|
||||
if(s.size == 0){
|
||||
delete index[tag]
|
||||
}
|
||||
}) })
|
||||
// remove empty sets...
|
||||
if(s.size == 0){
|
||||
delete index[tag]
|
||||
|
||||
// update...
|
||||
} else {
|
||||
index[tag] = s
|
||||
}
|
||||
})
|
||||
|
||||
return this
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user