* 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
()
| 905 | * deleting the oldest entry |
| 906 | */ |
| 907 | function createCache() { |
| 908 | var keys = []; |
| 909 | |
| 910 | function cache( key, value ) { |
| 911 | |
| 912 | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
| 913 | if ( keys.push( key + " " ) > Expr.cacheLength ) { |
| 914 | |
| 915 | // Only keep the most recent entries |
| 916 | delete cache[ keys.shift() ]; |
| 917 | } |
| 918 | return ( cache[ key + " " ] = value ); |
| 919 | } |
| 920 | return cache; |
| 921 | } |
| 922 | |
| 923 | /** |
| 924 | * Mark a function for special use by Sizzle |