* 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
()
| 1170 | * deleting the oldest entry |
| 1171 | */ |
| 1172 | function createCache() { |
| 1173 | var keys = []; |
| 1174 | |
| 1175 | function cache( key, value ) { |
| 1176 | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
| 1177 | if ( keys.push( key + " " ) > Expr.cacheLength ) { |
| 1178 | // Only keep the most recent entries |
| 1179 | delete cache[ keys.shift() ]; |
| 1180 | } |
| 1181 | return (cache[ key + " " ] = value); |
| 1182 | } |
| 1183 | return cache; |
| 1184 | } |
| 1185 | |
| 1186 | /** |
| 1187 | * Mark a function for special use by Sizzle |