Skip to content

Commit

Permalink
perf: improve CPU time
Browse files Browse the repository at this point in the history
  • Loading branch information
piquark6046 committed Aug 25, 2024
1 parent 9a4167b commit 3ee2664
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@list-kr/microshield-token-parser",
"type": "module",
"version": "1.0.5",
"version": "1.0.6",
"license": "Apache-2.0",
"scripts": {
"build": "pkgroll --src sources",
Expand Down
18 changes: 11 additions & 7 deletions sources/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,17 @@ export class AdvancedExtractor extends Extractor {

const TokenIdentifierNodes = FileInstance.getDescendantsOfKind(TsMorph.SyntaxKind.Identifier)
.filter(Identifier => {
return Identifier.getParent().getDescendantsOfKind(TsMorph.SyntaxKind.Identifier).length === 10
&& typeof Identifier.getFirstAncestorByKind(TsMorph.SyntaxKind.ReturnStatement) !== 'undefined'
&& (Identifier.getFirstAncestorByKind(TsMorph.SyntaxKind.ReturnStatement).getText().includes('.concat([')
|| Identifier.getFirstAncestorByKind(TsMorph.SyntaxKind.ReturnStatement).getText().includes('/resources/')
|| Identifier.getFirstAncestorByKind(TsMorph.SyntaxKind.ReturnStatement).getText().includes('.endpoint')
|| Identifier.getFirstAncestorByKind(TsMorph.SyntaxKind.ReturnStatement).getText().includes('token=')
|| Identifier.getFirstAncestorByKind(TsMorph.SyntaxKind.ReturnStatement).getText().includes('_'))
if (Identifier.getParent().getDescendantsOfKind(TsMorph.SyntaxKind.Identifier).length !== 10
|| typeof Identifier.getFirstAncestorByKind(TsMorph.SyntaxKind.ReturnStatement) === 'undefined') {
return false
}
const ReturnStatementText = Identifier.getFirstAncestorByKind(TsMorph.SyntaxKind.ReturnStatement).getText()
return ReturnStatementText.includes('.concat([')
|| ReturnStatementText.includes('/resources/')
|| ReturnStatementText.includes('.endpoint')
|| ReturnStatementText.includes('token=')
|| ReturnStatementText.includes('_')
|| ReturnStatementText.includes('resources://')
})
TokenIdentifierNodes.forEach(TokenIdentifier => {
const TokenDeclarationNode = TokenIdentifier.findReferences()[0].getDefinition().getDeclarationNode()
Expand Down

0 comments on commit 3ee2664

Please sign in to comment.