ruby-changes:36088
From: nobu <ko1@a...>
Date: Tue, 28 Oct 2014 11:53:43 +0900 (JST)
Subject: [ruby-changes:36088] nobu:r48169 (trunk): eventids2.c: reduce size
nobu 2014-10-28 11:53:24 +0900 (Tue, 28 Oct 2014) New Revision: 48169 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48169 Log: eventids2.c: reduce size * ext/ripper/eventids2.c (token_assoc): reduce size. unsigned short can hold 65535 at least. Modified files: trunk/ext/ripper/eventids2.c trunk/ext/ripper/tools/generate.rb Index: ext/ripper/tools/generate.rb =================================================================== --- ext/ripper/tools/generate.rb (revision 48168) +++ ext/ripper/tools/generate.rb (revision 48169) @@ -149,9 +149,13 @@ def read_ids1_with_locations(path) https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/generate.rb#L149 end def read_ids2(path) - File.open(path) {|f| - return f.read.scan(/ID\s+ripper_id_(\w+)/).flatten.uniq.sort - } + src = File.open(path) {|f| f.read} + ids2 = src.scan(/ID\s+ripper_id_(\w+)/).flatten.uniq.sort + diff = src.scan(/set_id2\((\w+)\);/).flatten - ids2 + unless diff.empty? + abort "missing scanner IDs: #{diff}" + end + return ids2 end main Index: ext/ripper/eventids2.c =================================================================== --- ext/ripper/eventids2.c (revision 48168) +++ ext/ripper/eventids2.c (revision 48169) @@ -125,11 +125,13 @@ ripper_init_eventids2(void) https://github.com/ruby/ruby/blob/trunk/ext/ripper/eventids2.c#L125 set_id2(CHAR); } +STATIC_ASSERT(k__END___range, k__END__ < SHRT_MAX); +STATIC_ASSERT(ripper_scanner_ids_size, sizeof(ripper_scanner_ids) < SHRT_MAX); #define O(member) (int)offsetof(ripper_scanner_ids_t, ripper_id_##member) static const struct token_assoc { - int token; - int id_offset; + unsigned short token; + unsigned short id_offset; } token_to_eventid[] = { {' ', O(words_sep)}, {'!', O(op)}, -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/