From 9b3e768bceae562deeb330067f3ef5febc2e5244 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 11 Feb 2020 16:16:43 -0500 Subject: Small improvements around List (#1216) * * Improved fastRemoveAt * Fixed off by one bug * Fixed const safeness with List<> * Made List begin and end const safe. * Revert to previous RefPtr usage. * Fix bug with casting. * Tabs -> spaces. Small fixes/improvements to List. * Improve comment on List. * hasContent -> isNonEmpty --- source/slang/slang-lexer.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source/slang/slang-lexer.h') diff --git a/source/slang/slang-lexer.h b/source/slang/slang-lexer.h index 0d19fe617..d1a1ba844 100644 --- a/source/slang/slang-lexer.h +++ b/source/slang/slang-lexer.h @@ -12,8 +12,8 @@ namespace Slang struct TokenList { - Token* begin() const; - Token* end() const; + const Token* begin() const; + const Token* end() const; SLANG_FORCE_INLINE void add(const Token& token) { m_tokens.add(token); } @@ -29,13 +29,13 @@ namespace Slang , m_end (tokenList.end ()) {} - Token* begin() const { return m_begin; } - Token* end () const { return m_end ; } + const Token* begin() const { return m_begin; } + const Token* end () const { return m_end ; } int getCount() { return (int)(m_end - m_begin); } - Token* m_begin; - Token* m_end; + const Token* m_begin; + const Token* m_end; }; struct TokenReader @@ -45,17 +45,17 @@ namespace Slang explicit TokenReader(TokenSpan const& tokens) : m_cursor(tokens.begin()) , m_end (tokens.end ()) - , m_nextToken(tokens.begin() ? *tokens.begin() : GetEndOfFileToken()) + , m_nextToken(tokens.begin() ? *tokens.begin() : getEndOfFileToken()) {} explicit TokenReader(TokenList const& tokens) : m_cursor(tokens.begin()) , m_end (tokens.end ()) - , m_nextToken(tokens.begin() ? *tokens.begin() : GetEndOfFileToken()) + , m_nextToken(tokens.begin() ? *tokens.begin() : getEndOfFileToken()) {} struct ParsingCursor { Token nextToken; - Token* tokenReaderCursor = nullptr; + const Token* tokenReaderCursor = nullptr; }; ParsingCursor getCursor() { @@ -78,9 +78,9 @@ namespace Slang int getCount() { return (int)(m_end - m_cursor); } - Token* m_cursor; - Token* m_end; - static Token GetEndOfFileToken(); + const Token* m_cursor; + const Token* m_end; + static Token getEndOfFileToken(); }; typedef unsigned int LexerFlags; -- cgit v1.2.3