D4465: httppeer: use our CBOR decoder
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Wed Sep 5 16:19:27 UTC 2018
indygreg added a comment.
In https://phab.mercurial-scm.org/D4465#68517, @pulkit wrote:
> Queued the cbor patches. I think following can improve the code more:
>
> - Having a `cborutil.decodeone()` function which can make sure we only have one dcoded value and using that fn instead of `decodeall()[0]`
> - A `cborutil.encode()` function to use where we don't want to do `streamencode()` and use that in place of `b''.join()` pattern
> - Checking for an empty string being passed in `cborutil.decodeall()[0]` or `cborutil.decodeone()`
>
> What do you think?
I agree with all these suggestions. I also think we should teach the `sansiodecoder` to decode at most one item and use that functionality to build `cborutil.decodeone()`.
FWIW one concern with going down that path is buffer over-read: if we're trying to decode a CBOR value from a stream without advancing past the end of the value, that can be difficult to do without feeding in data in small chunks. But it is doable.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4465
To: indygreg, #hg-reviewers, pulkit
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list