Added XPath::Compiler.compile_with_cache
This commit is contained in:
1 parent
6d01adafc7
commit
3300a6df49
2 files changed
+38
-4
No files matched your search
@@ -9,9 +9,21 @@ module Oga
|
||||
# recompiling the same expression over and over again.
|
||||
#
|
||||
class Compiler
|
||||
# @return [Oga::LRU]
|
||||
CACHE = LRU.new
|
||||
|
||||
# Wildcard for node names/namespace prefixes.
|
||||
STAR = '*'
|
||||
|
||||
##
|
||||
# Compiles and caches an AST.
|
||||
#
|
||||
# @see [#compile]
|
||||
#
|
||||
def self.compile_with_cache(ast)
|
||||
CACHE.get_or_set(ast) { new.compile(ast) }
|
||||
end
|
||||
|
||||
##
|
||||
# Compiles an XPath AST into a Ruby Proc.
|
||||
#
|
||||
|
||||
Reference in new issue
Block a user