Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kpu/kenlm
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Apr 11, 2017
2 parents f0c5a37 + f293fd9 commit c8ef1e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions lm/interpolate/tune_instances_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <vector>

#include <math.h>

namespace lm { namespace interpolate { namespace {

BOOST_AUTO_TEST_CASE(Toy) {
Expand Down
21 changes: 10 additions & 11 deletions util/file_piece.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,16 @@ FilePiece::FilePiece(std::istream &stream, const char *name, std::size_t min_buf
StringPiece FilePiece::ReadLine(char delim, bool strip_cr) {
std::size_t skip = 0;
while (true) {
for (const char *i = position_ + skip; i < position_end_; ++i) {
if (*i == delim) {
// End of line.
// Take 1 byte off the end if it's an unwanted carriage return.
const std::size_t subtract_cr = (
(strip_cr && i > position_ && *(i - 1) == '\r') ?
1 : 0);
StringPiece ret(position_, i - position_ - subtract_cr);
position_ = i + 1;
return ret;
}
const char *i = std::find(position_ + skip, position_end_, delim);
if (UTIL_LIKELY(i != position_end_)) {
// End of line.
// Take 1 byte off the end if it's an unwanted carriage return.
const std::size_t subtract_cr = (
(strip_cr && i > position_ && *(i - 1) == '\r') ?
1 : 0);
StringPiece ret(position_, i - position_ - subtract_cr);
position_ = i + 1;
return ret;
}
if (at_end_) {
if (position_ == position_end_) {
Expand Down

0 comments on commit c8ef1e3

Please sign in to comment.