chore: make cpu usage more smooth (#3842)
This commit is contained in:
@@ -25,7 +25,7 @@ func (b *filterBuilder) check(nodes ...*ast.TokenNode) {
|
||||
|
||||
func (b *filterBuilder) checkNodeWithPrefix(prefix string, nodes ...*ast.TokenNode) {
|
||||
for _, node := range nodes {
|
||||
joinText:=fmt.Sprintf("%s/%s",prefix,node.Token.Text)
|
||||
joinText := fmt.Sprintf("%s/%s", prefix, node.Token.Text)
|
||||
if _, ok := b.m[joinText]; ok {
|
||||
b.errorManager.add(ast.DuplicateStmtError(node.Pos(), "duplicate "+b.checkExprName))
|
||||
} else {
|
||||
|
||||
@@ -385,7 +385,7 @@ func (p *Parser) parsePathExpr() *ast.PathExpr {
|
||||
}
|
||||
|
||||
values = append(values, p.curTok)
|
||||
if p.peekTokenIs(token.LPAREN, token.Returns, token.AT_DOC, token.AT_HANDLER, token.SEMICOLON, token.RBRACE){
|
||||
if p.peekTokenIs(token.LPAREN, token.Returns, token.AT_DOC, token.AT_HANDLER, token.SEMICOLON, token.RBRACE) {
|
||||
break
|
||||
}
|
||||
if p.notExpectPeekTokenGotComment(p.curTokenNode().PeekFirstLeadingComment(), token.COLON, token.IDENT, token.INT) {
|
||||
|
||||
@@ -651,7 +651,7 @@ func NewScanner(filename string, src interface{}) (*Scanner, error) {
|
||||
}
|
||||
|
||||
func readData(filename string, src interface{}) ([]byte, error) {
|
||||
if strings.HasSuffix(filename, ".api") &&pathx.FileExists(filename){
|
||||
if strings.HasSuffix(filename, ".api") && pathx.FileExists(filename) {
|
||||
data, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user