Nuked Oga::XML::Lexer#html

This method was rather pointless since there's already a "html?" method.
This commit is contained in:
Yorick Peterse 2015-06-15 23:44:54 +02:00
parent 020cd34083
commit 4031c4f843
4 changed files with 6 additions and 10 deletions

View File

@ -28,7 +28,7 @@ on `ts` and `te`) so the macro ignores this argument.
ID id_advance_line; ID id_advance_line;
ID id_html_script_p; ID id_html_script_p;
ID id_html_style_p; ID id_html_style_p;
ID id_html; ID id_html_p;
%%machine c_lexer; %%machine c_lexer;
@ -81,7 +81,7 @@ VALUE oga_xml_lexer_advance(VALUE self, VALUE data_block)
int lines; int lines;
/* Whether or not HTML mode is enabled */ /* Whether or not HTML mode is enabled */
int html_p = rb_funcall(self, id_html, 0) == Qtrue; int html_p = rb_funcall(self, id_html_p, 0) == Qtrue;
/* Make sure that all data passed back to Ruby has the proper encoding. */ /* Make sure that all data passed back to Ruby has the proper encoding. */
rb_encoding *encoding = rb_enc_get(data_block); rb_encoding *encoding = rb_enc_get(data_block);
@ -189,7 +189,7 @@ void Init_liboga_xml_lexer()
id_advance_line = rb_intern("advance_line"); id_advance_line = rb_intern("advance_line");
id_html_script_p = rb_intern("html_script?"); id_html_script_p = rb_intern("html_script?");
id_html_style_p = rb_intern("html_style?"); id_html_style_p = rb_intern("html_style?");
id_html = rb_intern("html"); id_html_p = rb_intern("html?");
rb_define_method(cLexer, "advance_native", oga_xml_lexer_advance, 1); rb_define_method(cLexer, "advance_native", oga_xml_lexer_advance, 1);
rb_define_method(cLexer, "reset_native", oga_xml_lexer_reset, 0); rb_define_method(cLexer, "reset_native", oga_xml_lexer_reset, 0);

View File

@ -89,7 +89,7 @@ public class Lexer extends RubyObject
@JRubyMethod @JRubyMethod
public IRubyObject advance_native(ThreadContext context, RubyString rb_str) public IRubyObject advance_native(ThreadContext context, RubyString rb_str)
{ {
Boolean html_p = this.callMethod(context, "html").isTrue(); Boolean html_p = this.callMethod(context, "html?").isTrue();
Encoding encoding = rb_str.getEncoding(); Encoding encoding = rb_str.getEncoding();

View File

@ -34,14 +34,10 @@ module Oga
# However, it is perfectly save to use different instances per thread. # However, it is perfectly save to use different instances per thread.
# There is no _global_ state used by this lexer. # There is no _global_ state used by this lexer.
# #
# @!attribute [r] html
# @return [TrueClass|FalseClass]
# #
# @private # @private
# #
class Lexer class Lexer
attr_reader :html
# These are all constant/frozen to remove the need for String allocations # These are all constant/frozen to remove the need for String allocations
# every time they are referenced in the lexer. # every time they are referenced in the lexer.
HTML_SCRIPT = 'script'.freeze HTML_SCRIPT = 'script'.freeze
@ -206,7 +202,7 @@ module Oga
# @return [TrueClass|FalseClass] # @return [TrueClass|FalseClass]
# #
def html? def html?
return !!html return @html == true
end end
## ##

View File

@ -310,7 +310,7 @@ string_body
# @return [Oga::XML::Document] # @return [Oga::XML::Document]
# #
def on_document(children = []) def on_document(children = [])
document = Document.new(:type => @lexer.html ? :html : :xml) document = Document.new(:type => @lexer.html? ? :html : :xml)
children.each do |child| children.each do |child|
if child.is_a?(Doctype) if child.is_a?(Doctype)