From e01196e9ea8b502c075a58267c8e537a27fd8185 Mon Sep 17 00:00:00 2001 From: Dwi Siswanto Date: Mon, 29 Sep 2025 18:36:38 +0700 Subject: [PATCH] revert(templates): rm fast read parser Signed-off-by: Dwi Siswanto --- pkg/templates/compile.go | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/pkg/templates/compile.go b/pkg/templates/compile.go index 93c183307..e6563b59e 100644 --- a/pkg/templates/compile.go +++ b/pkg/templates/compile.go @@ -34,9 +34,6 @@ var ( ErrIncompatibleWithOfflineMatching = errors.New("template can't be used for offline matching") // track how many templates are verfied and by which signer SignatureStats = map[string]*atomic.Uint64{} - - parserAccessCache = map[*protocols.ExecutorOptions]*Parser{} - parserCacheMutex sync.RWMutex ) const ( @@ -48,8 +45,6 @@ func init() { SignatureStats[verifier.Identifier()] = &atomic.Uint64{} } SignatureStats[Unsigned] = &atomic.Uint64{} - - parserAccessCache = make(map[*protocols.ExecutorOptions]*Parser) } // updateRequestOptions updates options for all request types in a template @@ -171,28 +166,11 @@ func parseFromSource(filePath string, preprocessor Preprocessor, options *protoc // getParser returns a cached parser instance func getParser(options *protocols.ExecutorOptions) *Parser { - parserCacheMutex.RLock() - if parser, exists := parserAccessCache[options]; exists { - parserCacheMutex.RUnlock() - - return parser - } - parserCacheMutex.RUnlock() - - parserCacheMutex.Lock() - defer parserCacheMutex.Unlock() - - if parser, exists := parserAccessCache[options]; exists { - return parser - } - parser, ok := options.Parser.(*Parser) - if !ok { + if !ok || parser == nil { panic("invalid parser") } - parserAccessCache[options] = parser - return parser }