Skip to content

Commit 26cbe21

Browse files
committed
use if statement for better efficiency
1 parent f21d76e commit 26cbe21

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/targets/objc/helpers.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ module.exports = {
6464
case '[object Boolean]':
6565
return value ? '@YES' : '@NO'
6666
default:
67-
try {
68-
return '@"' + value.toString().replace(/"/g, '\\"') + '"'
69-
} catch (e) {
67+
if (value === null || value === undefined) {
7068
return ''
7169
}
70+
return '@"' + value.toString().replace(/"/g, '\\"') + '"'
7271
}
7372
}
7473
}

src/targets/swift/helpers.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ module.exports = {
7474
case '[object Boolean]':
7575
return value.toString()
7676
default:
77-
try {
78-
return '"' + value.toString().replace(/"/g, '\\"') + '"'
79-
} catch (e) {
77+
if (value === null || value === undefined) {
8078
return ''
8179
}
80+
return '"' + value.toString().replace(/"/g, '\\"') + '"'
8281
}
8382
}
8483
}

0 commit comments

Comments
 (0)