Skip to content

perf(dpi/bittorrent): build format_version string directly, drop per-byte String + Vec #348

@0xghost42

Description

@0xghost42

format_version in src/network/dpi/bittorrent.rs maps each kept byte to its own String ((b - b'0').to_string() / (b as char).to_string()), collects into a Vec<String>, then join("."). That allocates one String per byte plus the intermediate Vec on every client-version parse.

The two kept branches are also equivalent: ASCII digits are a subset of ASCII alphanumerics, and (b - b'0').to_string() equals (b as char).to_string() for digit bytes, so the digit branch is redundant.

Proposed: keep ASCII-alphanumeric bytes and push b as char into a single pre-sized String, separating with .. Same output, no per-byte String, no Vec. Happy to open the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions