[ruby/prism] Do not serialize node_id when PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS is set

* $ bundle exec rake serialized_size:topgems
Before:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  86284647
total serialized/total source: 0.957

Stats of ratio serialized/source per file:
average: 0.952
median:  0.937
1st quartile: 0.669
3rd quartile: 1.206
min - max: 0.080 - 4.065

After:
Total sizes for top 100 gems:
total source size:      90207647
total serialized size:  69477115
total serialized/total source: 0.770

Stats of ratio serialized/source per file:
average: 0.844
median:  0.825
1st quartile: 0.597
3rd quartile: 1.064
min - max: 0.078 - 3.792

https://github.com/ruby/prism/commit/cf90fe5759
This commit is contained in:
Benoit Daloze 2024-07-24 21:32:29 +02:00 коммит произвёл git
Родитель 22ad6b249b
Коммит 9cc2747ebb
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -74,7 +74,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
size_t offset = buffer->length;
<%- unless Prism::Template::SERIALIZE_ONLY_SEMANTICS_FIELDS -%>
pm_buffer_append_varuint(buffer, node->node_id);
<%- end -%>
pm_serialize_location(parser, &node->location, buffer);
switch (PM_NODE_TYPE(node)) {