Skip to content

Commit 7e0fe1a

Browse files
committed
only check once for the value of a boolean
1 parent d7c70b5 commit 7e0fe1a

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

src/slang-utils/metadata.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,19 @@ export function getNodeMetadata(
9999
offset += textLength.utf16;
100100
}
101101

102-
const leadingOffset = enclosePeripheralComments
103-
? 0
104-
: getLeadingOffset(children);
105-
const trailingOffset = enclosePeripheralComments
106-
? 0
107-
: getLeadingOffset(children.reverse());
108-
const loc = {
109-
start: initialOffset + leadingOffset,
110-
end: offset - trailingOffset,
111-
leadingOffset,
112-
trailingOffset
102+
const [leadingOffset, trailingOffset] = enclosePeripheralComments
103+
? [0, 0]
104+
: [getLeadingOffset(children), getLeadingOffset(children.reverse())];
105+
106+
return {
107+
comments,
108+
loc: {
109+
start: initialOffset + leadingOffset,
110+
end: offset - trailingOffset,
111+
leadingOffset,
112+
trailingOffset
113+
}
113114
};
114-
115-
return { comments, loc };
116115
}
117116

118117
function collectComments(

0 commit comments

Comments
 (0)