Permalink
Browse files

Remove hackish OverloadTag#to_a support to workaround create_tag(*tag…

…s) issue (and fix support in JRuby)
  • Loading branch information...
1 parent 0eabebb commit 72ccf6cec27314cdc2f8b32f60b918118e03ca02 @lsegal committed Mar 22, 2011
Showing with 13 additions and 6 deletions.
  1. +12 −0 benchmarks/splat_vs_flatten.rb
  2. +1 −1 lib/yard/docstring.rb
  3. +0 −5 lib/yard/tags/overload_tag.rb
@@ -0,0 +1,12 @@
+require "benchmark"
+
+# To prove that flattening a small list is not significantly slower than
+# calling *list (used to get around create_tag list issue)
+$a = "FOO BAR BAZ"
+def foo(*args) args.last.inspect end
+
+TESTS = 10_000
+Benchmark.bmbm do |x|
+ x.report("splat") { TESTS.times { foo *$a } }
+ x.report("flatten") { TESTS.times { foo *[$a].flatten } }
+end
@@ -199,7 +199,7 @@ def create_tag(tag_name, tag_buf)
tag_factory = Tags::Library.instance
tag_method = "#{tag_name}_tag"
if tag_name && tag_factory.respond_to?(tag_method)
- add_tag(*tag_factory.send(tag_method, tag_buf))
+ add_tag(*[tag_factory.send(tag_method, tag_buf)].flatten)
else
log.warn "Unknown tag @#{tag_name}" + (object ? " in file `#{object.file}` near line #{object.line}" : "")
end
@@ -37,11 +37,6 @@ def is_a?(other)
alias kind_of? is_a?
private
-
- if RUBY19
- def to_a; nil end
- def to_ary; nil end
- end
def parse_tag(text)
@signature, text = *text.split(/\r?\n/, 2)

0 comments on commit 72ccf6c

Please sign in to comment.