diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-10-05 11:50:43 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2022-11-24 14:27:19 -0800 |
commit | 1340195e79b8ae9cc56ebffc4241d6a5b2b12174 (patch) | |
tree | fbfeb85579873e8c167dc0a6c9e9b530ccbe01eb /pack.c | |
parent | f5d73da8062377e5b93100c6ea109a37bd04b4c1 (diff) | |
download | ruby-1340195e79b8ae9cc56ebffc4241d6a5b2b12174.tar.gz |
Reduce duplication in pack by sharing code for some cases
s/S, i/I, l/L, and q/Q had the same code in both cases, so
combine the cases.
Alternatively, we could actually the size of the unsigned type,
but I doubt there are any platforms where the unsigned type is
a different size than the signed type.
Diffstat (limited to 'pack.c')
-rw-r--r-- | pack.c | 16 |
1 files changed, 0 insertions, 16 deletions
@@ -477,40 +477,24 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer) goto pack_integer; case 's': /* s for int16_t, s! for signed short */ - integer_size = NATINT_LEN(short, 2); - bigendian_p = BIGENDIAN_P(); - goto pack_integer; - case 'S': /* S for uint16_t, S! for unsigned short */ integer_size = NATINT_LEN(short, 2); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'i': /* i and i! for signed int */ - integer_size = (int)sizeof(int); - bigendian_p = BIGENDIAN_P(); - goto pack_integer; - case 'I': /* I and I! for unsigned int */ integer_size = (int)sizeof(int); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'l': /* l for int32_t, l! for signed long */ - integer_size = NATINT_LEN(long, 4); - bigendian_p = BIGENDIAN_P(); - goto pack_integer; - case 'L': /* L for uint32_t, L! for unsigned long */ integer_size = NATINT_LEN(long, 4); bigendian_p = BIGENDIAN_P(); goto pack_integer; case 'q': /* q for int64_t, q! for signed long long */ - integer_size = NATINT_LEN_Q; - bigendian_p = BIGENDIAN_P(); - goto pack_integer; - case 'Q': /* Q for uint64_t, Q! for unsigned long long */ integer_size = NATINT_LEN_Q; bigendian_p = BIGENDIAN_P(); |