swc/crates/jsdoc
Kyuuhachi f2300dadbf
refactor(common): Debug-print spans more compactly (#8746)
**Description:**

`dbg!()` output on ASTs is kinda verbose,

```rs
ExprStmt {
    span: Span {
        lo: BytePos(
            37,
        ),
        hi: BytePos(
            50,
        ),
        ctxt: #0,
    },
    expr: Lit(
        Str(
            Str {
                span: Span {
                    lo: BytePos(
                        37,
                    ),
                    hi: BytePos(
                        49,
                    ),
                    ctxt: #0,
                },
                value: "use strict",
                raw: Some(
                    "\"use strict\"",
                ),
            },
        ),
    ),
}
```

A lot of the space is wasted on spans — 9 lines per span, even though
it's pretty much unimportant cruft. This PR changes that to just one
line per span:

```rs
ExprStmt {
    span: 37..50#0,
    expr: Lit(
        Str(
            Str {
                span: 37..49#0,
                value: "use strict",
                raw: Some(
                    "\"use strict\"",
                ),
            },
        ),
    ),
}
```

While not a statistically meaningful measurement, in my tests (sample
size = 1) this change reduces the `dbg!()` of a 1103-byte script from
5597 to 2885 lines, which is a 48% reduction. In `{:?}` mode it goes
from 40034 to 25457 chars, or 37% reduction.
2024-03-17 13:03:14 +00:00
..
src refactor(ast): Make serde optional (#7138) 2023-03-27 13:28:42 +09:00
tests refactor(common): Debug-print spans more compactly (#8746) 2024-03-17 13:03:14 +00:00
Cargo.toml chore: Bump crates 2024-03-14 01:32:37 +00:00