Skip to content

Commit 8f46c45

Browse files
committed
chore: Apply suggestion from code review
1 parent 955a752 commit 8f46c45

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/js/binaryen.js-post.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,12 +2776,11 @@ function wrapModule(module, self = {}) {
27762776
* Gets the memory segment with the given name.
27772777
*
27782778
* @param {string} name - The name of the memory segment to get.
2779-
* @returns {number} A MemorySegmentRef referring to the memory segment with the given name, or `null` if no such segment exists.
2779+
* @returns {number} A MemorySegmentRef referring to the memory segment with the given name, or `0` if no such segment exists.
27802780
*/
27812781
self['getMemorySegment'] = function(name) {
27822782
return preserveStack(() => {
2783-
const segment = Module['_BinaryenGetMemorySegment'](module, strToStack(name));
2784-
return segment === 0 ? null : segment;
2783+
return Module['_BinaryenGetMemorySegment'](module, strToStack(name));
27852784
});
27862785
};
27872786
/**

test/binaryen.js/kitchen-sink.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,8 @@ function test_for_each() {
11421142
data: expected_data[2].split('').map(function(x) { return x.charCodeAt(0) })
11431143
}
11441144
], false);
1145-
assert(module.getMemorySegment(expected_names[0]) !== null);
1146-
assert(module.getMemorySegment("NonExistantSegment") === null);
1145+
assert(module.getMemorySegment(expected_names[0]) !== 0);
1146+
assert(module.getMemorySegment("NonExistantSegment") === 0);
11471147
for (i = 0; i < module.getNumMemorySegments(); i++) {
11481148
var segment = module.getMemorySegmentByIndex(i);
11491149
var info = module.getMemorySegmentInfo(segment);

0 commit comments

Comments
 (0)