Skip to content

Add MessageUnpacker.tryUnpackNil() method#437

Merged
xerial merged 1 commit intodevelopfrom
unpacker-try-nil
Oct 21, 2017
Merged

Add MessageUnpacker.tryUnpackNil() method#437
xerial merged 1 commit intodevelopfrom
unpacker-try-nil

Conversation

@frsyuki
Copy link
Copy Markdown
Member

@frsyuki frsyuki commented Oct 14, 2017

When a code deals with an Optional value, a common way is to
serialize a Nil value if the value is absent. To deserialize it, we
check whether the next value is nil or not first. If it is nil, skip the
byte. Otherwise, read a value. For this common use case, tryUnpackNil
simplifies the deserialization code. It does "check whether the next
value is nil or not first. If it is nil, skip the byte" in one method
call.

When a code deals with an Optional<T> value, a common way is to
serialize a Nil value if the value is absent. To deserialize it, we
check whether the next value is nil or not first. If it is nil, skip the
byte. Otherwise, read a value. For this common use case, tryUnpackNil
simplifies the deserialization code. It does "check whether the next
value is nil or not first. If it is nil, skip the byte" in one method
call.
@xerial
Copy link
Copy Markdown
Member

xerial commented Oct 21, 2017

LGTM

@xerial xerial merged commit 53a24d7 into develop Oct 21, 2017
@xerial xerial deleted the unpacker-try-nil branch October 21, 2017 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants