summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2022-10-05 11:50:43 -0700
committerJeremy Evans <code@jeremyevans.net>2022-11-24 14:27:19 -0800
commit1340195e79b8ae9cc56ebffc4241d6a5b2b12174 (patch)
treefbfeb85579873e8c167dc0a6c9e9b530ccbe01eb /pack.c
parentf5d73da8062377e5b93100c6ea109a37bd04b4c1 (diff)
downloadruby-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.c16
1 files changed, 0 insertions, 16 deletions
diff --git a/pack.c b/pack.c
index 7ec0290de8..9ba9bacd89 100644
--- a/pack.c
+++ b/pack.c
@@ -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();