Skip to content

Commit fd0f1b6

Browse files
Tomonobu SaitoTomonobu Saito
authored andcommitted
fix by revier comments
1 parent 9c1c842 commit fd0f1b6

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

include/extractor/raster_source.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,21 @@ class RasterGrid
5454

5555
// Construct FileReader
5656
storage::io::FileReader file_reader(filepath, storage::io::FileReader::HasNoFingerprint);
57-
std::string buf;
58-
buf.resize(xdim * 11); // INT32_MAX = 2147483647 = 10 chars + 1 white space = 11
59-
BOOST_ASSERT(xdim * 11 <= buf.size());
57+
std::string buffer;
58+
buffer.resize(xdim * 11); // INT32_MAX = 2147483647 = 10 chars + 1 white space = 11
59+
BOOST_ASSERT(xdim * 11 <= buffer.size());
6060

6161
for (unsigned int y = 0; y < ydim; y++)
6262
{
6363
// read one line from file.
64-
file_reader.ReadLine(&buf[0], xdim * 11);
65-
boost::algorithm::trim(buf);
64+
file_reader.ReadLine(&buffer[0], xdim * 11);
65+
boost::algorithm::trim(buffer);
6666

6767
std::vector<std::string> result;
6868
boost::split(
69-
result, buf, boost::is_any_of(" \r\n\0"), boost::algorithm::token_compress_on);
70-
// boost::split(result, buf, boost::is_any_of(" \r\n\0"));
69+
result, buffer, boost::is_any_of(" \r\n\0"), boost::algorithm::token_compress_on);
7170
unsigned int x = 0;
72-
BOOST_FOREACH (std::string s, result)
71+
for (const auto &s : result)
7372
{
7473
if (x < xdim)
7574
_data[(y * xdim) + x] = atoi(s.c_str());

include/storage/io.hpp

100644100755
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,8 @@ class FileReader
8080
{
8181
if (0 < count)
8282
{
83-
const auto &ios =
84-
input_stream.getline(reinterpret_cast<char *>(dest), count * sizeof(T));
85-
for (std::size_t n = ios.gcount(); n < count; ++n)
86-
{
87-
reinterpret_cast<char *>(dest)[n] = '\0';
88-
}
83+
memset(dest, 0, count * sizeof(T));
84+
input_stream.getline(reinterpret_cast<char *>(dest), count * sizeof(T));
8985
}
9086
}
9187

0 commit comments

Comments
 (0)