Skip to content
Snippets Groups Projects
Commit a992c9ca authored by Jan Trávníček's avatar Jan Trávníček
Browse files

code optimize

parent e2010df8
No related branches found
No related tags found
No related merge requests found
...@@ -95,9 +95,7 @@ const SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::getChil ...@@ -95,9 +95,7 @@ const SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::getChil
} }
   
bool SuffixTrieNodeTerminatingSymbol::hasChild ( const DefaultSymbolType & symbol ) const { bool SuffixTrieNodeTerminatingSymbol::hasChild ( const DefaultSymbolType & symbol ) const {
if ( m_children.find ( symbol ) == m_children.end ( ) ) return false; return m_children.find ( symbol ) != m_children.end ( );
return true;
} }
   
SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::addChild ( DefaultSymbolType symbol, SuffixTrieNodeTerminatingSymbol node ) { SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::addChild ( DefaultSymbolType symbol, SuffixTrieNodeTerminatingSymbol node ) {
......
...@@ -89,9 +89,7 @@ bool xmlApi < object::Object >::first ( const ext::deque < sax::Token >::const_i ...@@ -89,9 +89,7 @@ bool xmlApi < object::Object >::first ( const ext::deque < sax::Token >::const_i
   
typename ext::map < std::string, std::unique_ptr < GroupParser > >::iterator callback = parseFunctions ( ).find ( tagName ); typename ext::map < std::string, std::unique_ptr < GroupParser > >::iterator callback = parseFunctions ( ).find ( tagName );
   
if ( callback == parseFunctions ( ).end ( ) ) return false; return callback != parseFunctions ( ).end ( );
return true;
} }
   
std::string xmlApi < object::Object >::xmlTagName ( ) { std::string xmlApi < object::Object >::xmlTagName ( ) {
......
...@@ -50,9 +50,7 @@ void FromXMLParserHelper::popToken(ext::deque<Token>::iterator& input, Token::To ...@@ -50,9 +50,7 @@ void FromXMLParserHelper::popToken(ext::deque<Token>::iterator& input, Token::To
std::string FromXMLParserHelper::popTokenData(ext::deque<Token>::iterator& input, Token::TokenType type) { std::string FromXMLParserHelper::popTokenData(ext::deque<Token>::iterator& input, Token::TokenType type) {
if(isTokenType(input, type)) { if(isTokenType(input, type)) {
skipAttributes ( input, type ); skipAttributes ( input, type );
std::string result = std::move(*input).moveData(); return std::move ( * input ++ ).getData ( );
++input;
return result;
} else { } else {
throw ParserException(Token("?", type), *input); throw ParserException(Token("?", type), *input);
} }
......
...@@ -11,21 +11,14 @@ ...@@ -11,21 +11,14 @@
   
namespace sax { namespace sax {
   
Token::Token(const std::string& tokenData, Token::TokenType tokenType) : Token::Token ( std::string tokenData, Token::TokenType tokenType ) : data ( std::move ( tokenData ) ), type ( tokenType ) {
data(tokenData), type(tokenType) {
}
Token::Token(std::string&& tokenData, Token::TokenType tokenType) :
data(std::move(tokenData)), type(tokenType) {
} }
   
const std::string& Token::getData() const { const std::string & Token::getData ( ) const & {
return data; return data;
} }
   
std::string&& Token::moveData() && { std::string && Token::getData ( ) && {
return std::move(data); return std::move(data);
} }
   
......
...@@ -29,18 +29,17 @@ private: ...@@ -29,18 +29,17 @@ private:
TokenType type; TokenType type;
   
public: public:
Token(const std::string&, TokenType); Token ( std::string, TokenType );
Token(std::string&&, TokenType);
   
/** /**
* @return name of the tag or characters read * @return name of the tag or characters read
*/ */
const std::string& getData() const; const std::string & getData ( ) const &;
   
/** /**
* @return name of the tag or characters read * @return name of the tag or characters read
*/ */
std::string&& moveData() &&; //TODO should be named getData only std::string && getData ( ) &&;
   
/** /**
* @return type of the token - star of the tag, end of the tag, attribute * @return type of the token - star of the tag, end of the tag, attribute
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment