Optimize TlBufferParser for empty strings.

GitOrigin-RevId: fb796f93d84a32c90f9420029b89e0f7fe169869
This commit is contained in:
levlam 2020-02-23 22:44:14 +03:00
parent c5f3b2223c
commit e34058c16f

View File

@ -48,6 +48,9 @@ void TlParser::set_error(const string &error_message) {
} }
BufferSlice TlBufferParser::as_buffer_slice(Slice slice) { BufferSlice TlBufferParser::as_buffer_slice(Slice slice) {
if (slice.empty()) {
return BufferSlice();
}
if (is_aligned_pointer<4>(slice.data())) { if (is_aligned_pointer<4>(slice.data())) {
return parent_->from_slice(slice); return parent_->from_slice(slice);
} }