Repository: JuliaLang/julia
File: src/timing.c (C)

Code before:
    //
    // Eventually, Tracy will support telling the server which fibers
    // are active upon connection, but until then we work around the
    // problem by not explicitly leaving the fiber at all.
    //
    // Later when we enter the new fiber directly, that will cause the
    // the active fiber to be left implicitly.

    //TracyCFiberLeave;
#endif
    (void)ct;

    jl_timing_block_t *blk = ptls->timing_stack;
    ptls->timing_stack = NULL;

    if (blk != NULL) {
        _COUNTS_PAUSE(&blk->counts_ctx, cycleclock());
    }
    return blk;
}

static void _jl_timing_show_buf(jl_timing_block_t *cur_block, ios_t *buf)
{
    if (buf->size == buf->maxsize) {
        memset(&buf->buf[IOS_INLSIZE - 4], '.', 3);
        buf->buf[buf->size-1] = '\0'; // Ensure null-termination
    }
    else {
        buf->buf[buf->size] = '\0'; // Ensure null-termination
    }
    jl_timing_puts(cur_block, buf->buf);
}

JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block)
{
#if defined(USE_TRACY) || defined(USE_APPLE_OSLOG)
    ios_t buf;
    ios_mem(&buf, IOS_INLSIZE);
    buf.growable = 0; // Restrict to inline buffer to avoid allocation

    jl_static_show((JL_STREAM*)&buf, v);
    _jl_timing_show_buf(cur_block, &buf);
#endif
}

JL_DLLEXPORT void jl_timing_show_module(jl_module_t *m, jl_timing_block_t *cur_block)
{
#if defined(USE_TRACY) || defined(USE_APPLE_OSLOG)
    jl_module_t *root = jl_module_root(m);
    if (root == m || root == jl_main_module) {
        const char *module_name = jl_symbol_name(m->name);

Review comment (suggestion):
```suggestion
        buf->size -= 1;
        buf->buf[buf->size] = '\0'; // Ensure null-termination
```

just to be consistent about whether the null terminator is included in the buffer or not

Code after:
    //
    // Eventually, Tracy will support telling the server which fibers
    // are active upon connection, but until then we work around the
    // problem by not explicitly leaving the fiber at all.
    //
    // Later when we enter the new fiber directly, that will cause the
    // the active fiber to be left implicitly.

    //TracyCFiberLeave;
#endif
    (void)ct;

    jl_timing_block_t *blk = ptls->timing_stack;
    ptls->timing_stack = NULL;

    if (blk != NULL) {
        _COUNTS_PAUSE(&blk->counts_ctx, cycleclock());
    }
    return blk;
}

static void _jl_timing_show_buf(jl_timing_block_t *cur_block, ios_t *buf)
{
    if (buf->size == buf->maxsize) {
        memset(&buf->buf[IOS_INLSIZE - 4], '.', 3);
        buf->size -= 1;
        buf->buf[buf->size] = '\0'; // Ensure null-termination
    }
    else {
        buf->buf[buf->size] = '\0'; // Ensure null-termination
    }
    jl_timing_puts(cur_block, buf->buf);
}

JL_DLLEXPORT void jl_timing_show(jl_value_t *v, jl_timing_block_t *cur_block)
{
#if defined(USE_TRACY) || defined(USE_APPLE_OSLOG)
    ios_t buf;
    ios_mem(&buf, IOS_INLSIZE);
    buf.growable = 0; // Restrict to inline buffer to avoid allocation

    jl_static_show((JL_STREAM*)&buf, v);
    _jl_timing_show_buf(cur_block, &buf);
#endif
}

JL_DLLEXPORT void jl_timing_show_module(jl_module_t *m, jl_timing_block_t *cur_block)
{
#if defined(USE_TRACY) || defined(USE_APPLE_OSLOG)
    jl_module_t *root = jl_module_root(m);
    if (root == m || root == jl_main_module) {