Problem
Small redundant allocations/work on secondary paths:
get_unverified_header / decode_unverified (rust/src/api.rs:343, :354): token.to_owned() just to move into detach — a &str can be captured directly. get_unverified_header also splits the token twice (ensure_valid_compact_jwt + parse_compact_header_json).
decode_unverified uses dangerous::insecure_decode, which parses the header more than once; the single-pass helpers in jws.rs can be reused.
decode_verified_complete (rust/src/api.rs:240-243): token is split again and the signature base64-decoded twice (once inside jwt_crypto_verify, once in extract_signature_bytes).
jws_parse_compact copies the token and returns a signing_input bytes object that the only Python caller discards (_s in api_jwt.py).
encode_json (rust/src/api.rs:444, :452-458): payload_bytes.to_vec() plus two format! allocations — can build the final token in one pre-sized String.
Acceptance criteria
Files
rust/src/api.rs, rust/src/jws.rs, python/oxyjwt/api_jwt.py
Branch
issue/<N>-minor-alloc-cleanup from dev
Problem
Small redundant allocations/work on secondary paths:
get_unverified_header/decode_unverified(rust/src/api.rs:343,:354):token.to_owned()just to move intodetach— a&strcan be captured directly.get_unverified_headeralso splits the token twice (ensure_valid_compact_jwt+parse_compact_header_json).decode_unverifiedusesdangerous::insecure_decode, which parses the header more than once; the single-pass helpers injws.rscan be reused.decode_verified_complete(rust/src/api.rs:240-243): token is split again and the signature base64-decoded twice (once insidejwt_crypto_verify, once inextract_signature_bytes).jws_parse_compactcopies the token and returns asigning_inputbytes object that the only Python caller discards (_sinapi_jwt.py).encode_json(rust/src/api.rs:444,:452-458):payload_bytes.to_vec()plus twoformat!allocations — can build the final token in one pre-sizedString.Acceptance criteria
Files
rust/src/api.rs,rust/src/jws.rs,python/oxyjwt/api_jwt.pyBranch
issue/<N>-minor-alloc-cleanupfromdev