Added CSS/XPath Parser.parse_with_cache
This method parses and caches ASTs using Oga::LRU. Currently the default of 1024 keys is used. See #71 for more information.
This commit is contained in:
1 parent
67d7d9af88
commit
2c4e490614
6 files changed
+94
-2
No files matched your search
@@ -310,6 +310,19 @@ even
|
||||
|
||||
%inner
|
||||
{
|
||||
##
|
||||
# @return [Oga::LRU]
|
||||
#
|
||||
CACHE = LRU.new
|
||||
|
||||
##
|
||||
# @param [String] data
|
||||
# @return [AST::Node]
|
||||
#
|
||||
def self.parse_with_cache(data)
|
||||
return CACHE.get_or_set(data) { new(data).parse }
|
||||
end
|
||||
|
||||
##
|
||||
# @param [String] data The input to parse.
|
||||
#
|
||||
|
||||
@@ -223,6 +223,19 @@ variable
|
||||
|
||||
%inner
|
||||
{
|
||||
##
|
||||
# @return [Oga::LRU]
|
||||
#
|
||||
CACHE = LRU.new
|
||||
|
||||
##
|
||||
# @param [String] data
|
||||
# @return [AST::Node]
|
||||
#
|
||||
def self.parse_with_cache(data)
|
||||
return CACHE.get_or_set(data) { new(data).parse }
|
||||
end
|
||||
|
||||
##
|
||||
# @param [String] data The input to parse.
|
||||
#
|
||||
|
||||
Reference in new issue
Block a user