diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-06-21 18:04:30 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-06-21 19:29:54 +0900 |
| commit | 318c804504e32b7a0bbdbb35336d2e918000d80a (patch) | |
| tree | fad396aee04c44a29ee79b33e1675db2275146c0 /src/IOFile.cc | |
| parent | 8ba9b0474747185708a25943fb6d2f97b3d9b17f (diff) | |
Use user-defined literal for k, m, and g (powers of 1024)
Diffstat (limited to 'src/IOFile.cc')
| -rw-r--r-- | src/IOFile.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/IOFile.cc b/src/IOFile.cc index 3cf01c69..9df2ebc4 100644 --- a/src/IOFile.cc +++ b/src/IOFile.cc @@ -91,15 +91,15 @@ std::string IOFile::getLine() if(eof()) { return res; } - char buf[4096]; - while(gets(buf, sizeof(buf))) { - size_t len = strlen(buf); + std::array<char, 4_k> buf; + while(gets(buf.data(), buf.size())) { + size_t len = strlen(buf.data()); bool lineBreak = false; if(buf[len-1] == '\n') { --len; lineBreak = true; } - res.append(buf, len); + res.append(buf.data(), len); if(lineBreak) { break; } @@ -120,12 +120,12 @@ bool IOFile::eof() size_t IOFile::transfer(std::ostream& out) { size_t count = 0; - char buf[4096]; + std::array<char, 4_k> buf; while(1) { - size_t r = this->read(buf, sizeof(buf)); - out.write(buf, r); + size_t r = this->read(buf.data(), buf.size()); + out.write(buf.data(), r); count += r; - if(r < sizeof(buf)) { + if(r < buf.size()) { break; } } |
