Merge ca1e096ed5
into 66187a77cf
commit
d4ee164cf1
|
@ -155,7 +155,7 @@ AI_FORCE_INLINE LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_emp
|
|||
mSkip_empty_lines(skip_empty_lines),
|
||||
mTrim(trim) {
|
||||
mCur.reserve(1024);
|
||||
mEnd = mCur.c_str() + 1024;
|
||||
mEnd = mCur.c_str() + mCur.capacity();
|
||||
operator++();
|
||||
mIdx = 0;
|
||||
}
|
||||
|
@ -172,6 +172,7 @@ AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() {
|
|||
|
||||
char s;
|
||||
mCur.clear();
|
||||
mEnd = mCur.c_str() + mCur.capacity();
|
||||
while (mStream.GetRemainingSize() && (s = mStream.GetI1(), 1)) {
|
||||
if (s == '\n' || s == '\r') {
|
||||
if (mSkip_empty_lines) {
|
||||
|
@ -194,6 +195,7 @@ AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() {
|
|||
break;
|
||||
}
|
||||
mCur += s;
|
||||
mEnd = mCur.c_str() + mCur.capacity();
|
||||
}
|
||||
++mIdx;
|
||||
|
||||
|
|
|
@ -103,11 +103,11 @@ AI_FORCE_INLINE bool IsSpaceOrNewLine(char_t in) {
|
|||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out, const char_t *end) {
|
||||
while ((*in == (char_t)' ' || *in == (char_t)'\t') && in != end) {
|
||||
while (in < end && (*in == (char_t)' ' || *in == (char_t)'\t')) {
|
||||
++in;
|
||||
}
|
||||
*out = in;
|
||||
return !IsLineEnd<char_t>(*in);
|
||||
return in < end && !IsLineEnd<char_t>(*in);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -119,16 +119,16 @@ AI_FORCE_INLINE bool SkipSpaces(const char_t **inout, const char_t *end) {
|
|||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out, const char_t *end) {
|
||||
while ((*in != (char_t)'\r' && *in != (char_t)'\n' && *in != (char_t)'\0') && in != end) {
|
||||
while (in < end && (*in != (char_t)'\r' && *in != (char_t)'\n' && *in != (char_t)'\0')) {
|
||||
++in;
|
||||
}
|
||||
|
||||
// files are opened in binary mode. Ergo there are both NL and CR
|
||||
while ((*in == (char_t)'\r' || *in == (char_t)'\n') && in != end) {
|
||||
while (in < end && (*in == (char_t)'\r' || *in == (char_t)'\n')) {
|
||||
++in;
|
||||
}
|
||||
*out = in;
|
||||
return *in != (char_t)'\0';
|
||||
return in < end && *in != (char_t)'\0';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -140,11 +140,11 @@ AI_FORCE_INLINE bool SkipLine(const char_t **inout, const char_t *end) {
|
|||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out, const char_t *end) {
|
||||
while ((*in == (char_t)' ' || *in == (char_t)'\t' || *in == (char_t)'\r' || *in == (char_t)'\n') && in != end) {
|
||||
while (in < end && (*in == (char_t)' ' || *in == (char_t)'\t' || *in == (char_t)'\r' || *in == (char_t)'\n')) {
|
||||
++in;
|
||||
}
|
||||
*out = in;
|
||||
return *in != '\0';
|
||||
return in < end && *in != '\0';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue