mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Use implicit boolean casts; it doesn't hurt performance
This commit is contained in:
@@ -17,19 +17,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T {
|
||||
if (node !== void 0) {
|
||||
if (node) {
|
||||
return cbNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes: Node[]) {
|
||||
if (nodes !== void 0) {
|
||||
if (nodes) {
|
||||
return cbNodes(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
function visitEachNode<T>(cbNode: (node: Node) => T, nodes: Node[]) {
|
||||
if (nodes !== void 0) {
|
||||
if (nodes) {
|
||||
for (const node of nodes) {
|
||||
const result = cbNode(node);
|
||||
if (result) {
|
||||
@@ -44,7 +44,7 @@ namespace ts {
|
||||
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
|
||||
// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
|
||||
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T {
|
||||
if (node === void 0) {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
// The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray
|
||||
|
||||
Reference in New Issue
Block a user