mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
`fetch` classified the response with `parse_syndication_body` — which parses the whole body into a `serde_json::Value` — and then threw that value away and re-parsed the same text into a `SyndicationTweet`. Two full JSON scans and two allocations of every string in the body (text, entities, media details) per tweet. `Tweet::from_syndication_value` takes the value classification already built and deserializes from that: `from_value` moves the strings out of the tree instead of allocating copies, so the response text is scanned once. The auth fallback had the mirror image of the same waste — it built the syndication shape as a `Value` and then serialized it back to a string for a parse — and the 8 test call sites lose their `.to_string()` with it. Verified live: `cargo test -p x-media -- --ignored live` (14 passed), including the 5 twitter fetches that exercise this path. `cargo fmt --check`, `cargo clippy --workspace --all-targets --locked -- -D warnings` and `cargo test --workspace --locked` clean.