diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-20 16:57:33 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-21 15:25:58 +0900 |
| commit | 36632f55f418bd711112b72d7fe1b6b1745058e5 (patch) | |
| tree | 30a9a0e83fced5759b5da8f2354b7ba02280e2b8 /src/symbol.c | |
| parent | 4ea80913c27264df0c7088367109c5a0678879f1 (diff) | |
| download | mruby-36632f55f418bd711112b72d7fe1b6b1745058e5.tar.gz mruby-36632f55f418bd711112b72d7fe1b6b1745058e5.zip | |
boxing_word.h: embed `mrb_float` in `mrb_value` if possible.
Embedding reduce memory consumption, sacrificing precision. It clips least
significant 2 bits from `mrb_float`, so if you need to keep float precision,
define `MRB_USE_FLOAT_FULL_PRECISION`.
`MRB_WORD_BOXING` and `MRB_INT64`:
`mrb_float` (`double`) is embedded in `mrb_value` clipped last 2 bits.
`MRB_WORD_BOXING` and `MRB_INT64` and `MRB_USE_FLOAT_FULL_PRECISION`:
`mrb_float` is allocated in the heaps wrapped by `struct RFloat`.
`MRB_WORD_BOXING` and `MRB_INT32` and `MRB_USE_FLOAT32`:
`mrb_float` (`float`) is embedded in `mrb_value` clipped last 2 bits.
In addition, to reserve bit space in the `mrb_value`, maximum inline
symbol length become 4 (instead of 5) in the configuration.
`MRB_WORD_BOXING` and `MRB_INT32`:
Assume `MRB_USE_FLOAT_FULL_PRECISION` and allocate Float values in heap.
Diffstat (limited to 'src/symbol.c')
| -rw-r--r-- | src/symbol.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/symbol.c b/src/symbol.c index 9d68b5cf3..dbdeca459 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -73,7 +73,11 @@ static const char pack_table[] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS static mrb_sym sym_inline_pack(const char *name, size_t len) { +#if defined(MRB_WORD_BOXING) && defined(MRB_32BIT) && !defined(MRB_USE_FLOAT_FULL_PRECISION) + const size_t pack_length_max = 4; +#else const size_t pack_length_max = 5; +#endif char c; const char *p; |
