From fd6cc9689167d403e1a2c1a247e09bfbb0c4fd6e Mon Sep 17 00:00:00 2001 From: Youssef Makboul Date: Wed, 29 May 2024 12:21:59 -0400 Subject: [PATCH] Disable ruby fallback --- lib/liquid/c.rb | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/lib/liquid/c.rb b/lib/liquid/c.rb index eba53435..aa02ebd0 100644 --- a/lib/liquid/c.rb +++ b/lib/liquid/c.rb @@ -73,17 +73,9 @@ def new_block_body alias_method :ruby_new_tokenizer, :new_tokenizer def new_tokenizer(source, start_line_number: nil, for_liquid_tag: false) - unless liquid_c_nodes_disabled? - source = source.to_s.to_str - if source.bytesize <= Liquid::C::Tokenizer::MAX_SOURCE_BYTE_SIZE - source = source.encode(Encoding::UTF_8) - return Liquid::C::Tokenizer.new(source, start_line_number || 0, for_liquid_tag) - else - @liquid_c_nodes_disabled = true - end - end - - ruby_new_tokenizer(source, start_line_number: start_line_number, for_liquid_tag: for_liquid_tag) + source = source.to_s.to_str + source = source.encode(Encoding::UTF_8) + Liquid::C::Tokenizer.new(source, start_line_number || 0, for_liquid_tag) end def parse_expression(markup) @@ -96,15 +88,7 @@ def parse_expression(markup) # @api private def liquid_c_nodes_disabled? - # Liquid::Profiler exposes the internal parse tree that we don't want to build when - # parsing with liquid-c, so consider liquid-c to be disabled when using it. - # Also, some templates are parsed before the profiler is running, on which case we - # provide the `disable_liquid_c_nodes` option to enable the Ruby AST to be produced - # so the profiler can use it on future runs. - return @liquid_c_nodes_disabled if defined?(@liquid_c_nodes_disabled) - - @liquid_c_nodes_disabled = !Liquid::C.enabled || @template_options[:profile] || - @template_options[:disable_liquid_c_nodes] || self.class.liquid_c_nodes_disabled + false end end