diff options
author | tompng <[email protected]> | 2024-02-29 01:36:14 +0900 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-03-07 18:02:33 -0500 |
commit | 81f02eb6ba6104899035378f1f93b11448d44505 (patch) | |
tree | a286b5a2b71ffbf65fd1c8792a0c22fe84f15c06 /prism/static_literals.c | |
parent | 5113d6b0591fe2c80cace33654e9088d1330277c (diff) |
[ruby/prism] Change pm_integer_t structure
https://github.com/ruby/prism/commit/588acf823f
Diffstat (limited to 'prism/static_literals.c')
-rw-r--r-- | prism/static_literals.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/prism/static_literals.c b/prism/static_literals.c index 713721bb73..81231692f6 100644 --- a/prism/static_literals.c +++ b/prism/static_literals.c @@ -53,12 +53,11 @@ node_hash(const pm_parser_t *parser, const pm_node_t *node) { case PM_INTEGER_NODE: { // Integers hash their value. const pm_integer_t *integer = &((const pm_integer_node_t *) node)->value; - const uint32_t *value = &integer->head.value; - - uint32_t hash = murmur_hash((const uint8_t *) value, sizeof(uint32_t)); - for (const pm_integer_word_t *word = integer->head.next; word != NULL; word = word->next) { - value = &word->value; - hash ^= murmur_hash((const uint8_t *) value, sizeof(uint32_t)); + uint32_t hash; + if (integer->values) { + hash = murmur_hash((const uint8_t *) integer->values, sizeof(uint32_t) * integer->length); + } else { + hash = murmur_hash((const uint8_t *) &integer->value, sizeof(uint32_t)); } if (integer->negative) { @@ -204,9 +203,9 @@ pm_int64_value(const pm_parser_t *parser, const pm_node_t *node) { switch (PM_NODE_TYPE(node)) { case PM_INTEGER_NODE: { const pm_integer_t *integer = &((const pm_integer_node_t *) node)->value; - if (integer->length > 0) return integer->negative ? INT64_MIN : INT64_MAX; + if (integer->values) return integer->negative ? INT64_MIN : INT64_MAX; - int64_t value = (int64_t) integer->head.value; + int64_t value = (int64_t) integer->value; return integer->negative ? -value : value; } case PM_SOURCE_LINE_NODE: |