* 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
()
| 891 | * deleting the oldest entry |
| 892 | */ |
| 893 | function createCache() { |
| 894 | var keys = []; |
| 895 | |
| 896 | function cache( key, value ) { |
| 897 | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
| 898 | if ( keys.push( key + " " ) > Expr.cacheLength ) { |
| 899 | // Only keep the most recent entries |
| 900 | delete cache[ keys.shift() ]; |
| 901 | } |
| 902 | return (cache[ key + " " ] = value); |
| 903 | } |
| 904 | return cache; |
| 905 | } |
| 906 | |
| 907 | /** |
| 908 | * Mark a function for special use by Sizzle |