diff options
author | Peter Zhu <[email protected]> | 2022-01-07 14:15:42 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2022-01-07 14:22:32 -0500 |
commit | d9ef711f296afbe2a029961e83a03d023ca29f15 (patch) | |
tree | cd2da27bca58dbf3ff37b0c55661949a98a79e87 /gc.c | |
parent | c365c5921ea26e31c03a85b01ff4c04629abfc10 (diff) |
Improve string info in rb_raw_obj_info
Improve rb_raw_obj_info to output additional into about strings
including the length, capacity, and whether or not it is embedded.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5414
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -13304,8 +13304,15 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj) } break; case T_STRING: { - if (STR_SHARED_P(obj)) APPENDF((BUFF_ARGS, " [shared] ")); - APPENDF((BUFF_ARGS, "%.*s", str_len_no_raise(obj), RSTRING_PTR(obj))); + if (STR_SHARED_P(obj)) { + APPENDF((BUFF_ARGS, " [shared] len: %ld", RSTRING_LEN(obj))); + } + else { + if (STR_EMBED_P(obj)) APPENDF((BUFF_ARGS, " [embed]")); + + APPENDF((BUFF_ARGS, " len: %ld, capa: %ld", RSTRING_LEN(obj), rb_str_capacity(obj))); + } + APPENDF((BUFF_ARGS, " \"%.*s\"", str_len_no_raise(obj), RSTRING_PTR(obj))); break; } case T_SYMBOL: { |