Token *createNode(const Token &V) {
return new (Alloc.Allocate<Token>()) Token(V);
}
- static void deleteNode(Token *V) {}
+ static void deleteNode(Token *V) { V->~Token(); }
void addNodeToList(Token *) {}
void removeNodeFromList(Token *) {}
removeStaleSimpleKeyCandidates();
SimpleKey SK;
- SK.Tok = TokenQueue.front();
+ SK.Tok = TokenQueue.begin();
if (std::find(SimpleKeys.begin(), SimpleKeys.end(), SK)
== SimpleKeys.end())
break;
bool Scanner::isBlankOrBreak(StringRef::iterator Position) {
if (Position == End)
return false;
- if ( *Position == ' ' || *Position == '\t'
- || *Position == '\r' || *Position == '\n')
- return true;
- return false;
+ return *Position == ' ' || *Position == '\t' || *Position == '\r' ||
+ *Position == '\n';
}
bool Scanner::consumeLineBreakIfPresent() {
TokenQueue.push_back(T);
// [ and { may begin a simple key.
- saveSimpleKeyCandidate(TokenQueue.back(), Column - 1, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), Column - 1, false);
// And may also be followed by a simple key.
IsSimpleKeyAllowed = true;
T.Range = StringRef(Start, Current - Start);
TokenQueue.push_back(T);
- saveSimpleKeyCandidate(TokenQueue.back(), ColStart, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), ColStart, false);
IsSimpleKeyAllowed = false;
TokenQueue.push_back(T);
// Plain scalars can be simple keys.
- saveSimpleKeyCandidate(TokenQueue.back(), ColStart, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), ColStart, false);
IsSimpleKeyAllowed = false;
TokenQueue.push_back(T);
// Alias and anchors can be simple keys.
- saveSimpleKeyCandidate(TokenQueue.back(), ColStart, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), ColStart, false);
IsSimpleKeyAllowed = false;
TokenQueue.push_back(T);
// Tags can be simple keys.
- saveSimpleKeyCandidate(TokenQueue.back(), ColStart, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), ColStart, false);
IsSimpleKeyAllowed = false;
, AnchorInfo.Range.substr(1)
, TagInfo.Range
, T.Range);
- case Token::TK_BlockScalar:
+ case Token::TK_BlockScalar: {
getNext();
+ StringRef NullTerminatedStr(T.Value.c_str(), T.Value.length() + 1);
+ StringRef StrCopy = NullTerminatedStr.copy(NodeAllocator).drop_back();
return new (NodeAllocator)
BlockScalarNode(stream.CurrentDoc, AnchorInfo.Range.substr(1),
- TagInfo.Range, T.Value, T.Range);
+ TagInfo.Range, StrCopy, T.Range);
+ }
case Token::TK_Key:
// Don't eat the TK_Key, KeyValueNode expects it.
return new (NodeAllocator)