[RandomAccessInputStream] Use tstring::resize_uninitialized() in ReadNBytes().

This avoids unnecessarily `memset`ting the bytes that are about to be overwritten.

PiperOrigin-RevId: 293855502
Change-Id: Ibad17f55e160b79137564a23ca8beb2c2eafab0b
This commit is contained in:
Derek Murray 2020-02-07 11:22:00 -08:00 committed by TensorFlower Gardener
parent 2761aba394
commit 851a0b6651

View File

@ -35,7 +35,7 @@ Status RandomAccessInputStream::ReadNBytes(int64 bytes_to_read,
return errors::InvalidArgument("Cannot read negative number of bytes");
}
result->clear();
result->resize(bytes_to_read);
result->resize_uninitialized(bytes_to_read);
char* result_buffer = &(*result)[0];
StringPiece data;
Status s = file_->Read(pos_, bytes_to_read, &data, result_buffer);