* Create key-value caches of limited size * @returns {Function(string, Object)} Returns the Object data after storing it on itself with * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) * deleting the oldest entry
()
| 1166 | * deleting the oldest entry |
| 1167 | */ |
| 1168 | function createCache() { |
| 1169 | var keys = []; |
| 1170 | |
| 1171 | function cache( key, value ) { |
| 1172 | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
| 1173 | if ( keys.push( key += " " ) > Expr.cacheLength ) { |
| 1174 | // Only keep the most recent entries |
| 1175 | delete cache[ keys.shift() ]; |
| 1176 | } |
| 1177 | return (cache[ key ] = value); |
| 1178 | } |
| 1179 | return cache; |
| 1180 | } |
| 1181 | |
| 1182 | /** |
| 1183 | * Mark a function for special use by Sizzle |