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.
This commit is contained in:
Peter Zhu 2022-01-07 14:15:42 -05:00
Родитель c365c5921e
Коммит d9ef711f29
1 изменённых файлов: 9 добавлений и 2 удалений

11
gc.c
Просмотреть файл

@ -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: {