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:
Yorick Peterse committed 2015-03-23 00:22:59 +01:00
1 parent 67d7d9af88
commit 2c4e490614
6 files changed
+94 -2

No files matched your search

+13
View File
@@ -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.
#
+13
View File
@@ -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.
#