librasn / rasn

A Safe #[no_std] ASN.1 Codec Framework
Other
183 stars 43 forks source link

perf(ber): don't allocate `2 + N` `BigInt`s when parsing OIDs #263

Closed repnop closed 2 weeks ago

repnop commented 2 weeks ago

the BigInts that are used to parse OIDs are downcasted to u32s later on in the code anyway, so now that we have fixed-sized integer parsing that doesn't roundtrip through BigInts, we can just attempt to deserialize them as u32s instead of allocating a bunch. this bought me a ~(-72%) benchmark win on parsing an SNMP packet since every varbind value has an associated OID, and got the parse time below netsnmp's PDU decode for my microbenchmark :)

repnop commented 2 weeks ago

looks like clippy got some new lints for doc comment formatting, so I added that in as well just so it won't be a problem for future PRs, if that's okay. I can split it off in its ownPR but figured since it was like ~3-4 lines of changes it'd be fine to just sneak in with this

XAMPPRocky commented 2 weeks ago

Thank you for your PR!