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