Skip to content

Commit 657eafb

Browse files
committed
small optimisations when we only need the destructured node
1 parent 364beac commit 657eafb

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

src/slang-comments/printer.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { isComment } from '../slang-utils/is-comment.js';
33
import type { AstPath, Doc } from 'prettier';
44
import type { AstNode } from '../slang-nodes/types.d.ts';
55

6-
export function printComment(commentPath: AstPath<AstNode>): Doc {
7-
const { node: comment } = commentPath;
8-
6+
export function printComment({ node: comment }: AstPath<AstNode>): Doc {
97
if (isComment(comment)) {
108
return comment.print();
119
}

src/slangPrinter.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ function ignoreComments(path: AstPath<AstNode>): void {
3535
break;
3636
// The key `comments` will contain every comment for this node
3737
case 'comments':
38-
path.each((commentPath) => {
39-
const { node: comment } = commentPath;
40-
comment.printed = true;
41-
}, 'comments');
38+
path.each((commentPath) => (commentPath.node.printed = true), key);
4239
break;
4340
default:
4441
// If the value for that key is an Array or an Object we go deeper.

0 commit comments

Comments
 (0)