Refactor format_darray_pretty for readability

This commit is contained in:
Cary R. 2026-07-12 07:52:48 -07:00 committed by GitHub
parent 82350c4866
commit 9a7178fef0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 6 deletions

View File

@ -120,14 +120,12 @@ static char* vpip_format_pretty_string(const char*msg)
static char* format_darray_pretty(vvp_darray* aobj)
{
if (!aobj || aobj->get_size() == 0)
return strdup("{}");
if (!aobj || aobj->get_size() == 0) return strdup("{}");
std::string out = "{";
for (size_t i = 0; i < aobj->get_size(); i += 1) {
if (i > 0)
out += ", ";
if (i > 0) out += ", ";
if (dynamic_cast<vvp_darray_real*>(aobj)) {
double d;
aobj->get_word((unsigned) i, d);
@ -156,14 +154,16 @@ static char* format_darray_pretty(vvp_darray* aobj)
extern "C" char* vpip_format_pretty(vpiHandle ref)
{
if (!ref)
if (!ref) {
return vpip_format_pretty_string("Handle is NULL");
}
if (dynamic_cast<__vpiPropQueueRef*>(ref) ||
dynamic_cast<__vpiDarrayVar*>(ref)) {
vvp_darray* aobj = vpip_vpi_darray_from_handle(ref);
if (!aobj)
if (!aobj) {
return vpip_format_pretty_string("Object not found");
}
return format_darray_pretty(aobj);
}