Refactor push_byte's code
Move logic below error checking with early exit.
This commit is contained in:
parent
9ca00c5b8c
commit
e3f554218a
1 changed files with 1 additions and 1 deletions
|
|
@ -100,7 +100,6 @@ impl MessageReader {
|
||||||
self.read_bytes += 1;
|
self.read_bytes += 1;
|
||||||
if self.read_bytes >= UE_LENGTH_FIELD_SIZE {
|
if self.read_bytes >= UE_LENGTH_FIELD_SIZE {
|
||||||
self.current_message_length = array_of_u8_to_u32(self.length_buffer) as usize;
|
self.current_message_length = array_of_u8_to_u32(self.length_buffer) as usize;
|
||||||
self.change_state(ReadingState::Payload);
|
|
||||||
if self.current_message_length > MAX_UE_MESSAGE_LENGTH {
|
if self.current_message_length > MAX_UE_MESSAGE_LENGTH {
|
||||||
self.is_broken = true;
|
self.is_broken = true;
|
||||||
return Err(ReadingStreamError::MessageTooLong {
|
return Err(ReadingStreamError::MessageTooLong {
|
||||||
|
|
@ -108,6 +107,7 @@ impl MessageReader {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self.current_message = Vec::with_capacity(self.current_message_length);
|
self.current_message = Vec::with_capacity(self.current_message_length);
|
||||||
|
self.change_state(ReadingState::Payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReadingState::Payload => {
|
ReadingState::Payload => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue