зеркало из https://github.com/github/ruby.git
eventids2.c: reduce size
* ext/ripper/eventids2.c (token_assoc): reduce size. unsigned short can hold 65535 at least. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
d3dc67350a
Коммит
b5524d9f8a
|
@ -125,11 +125,13 @@ ripper_init_eventids2(void)
|
|||
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)},
|
||||
|
|
|
@ -149,9 +149,13 @@ def read_ids1_with_locations(path)
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче