-1 is an impossible state

pull/12073/head
Rich Harris 9 months ago
parent 5b11c396f2
commit 45acc8f8fe

@ -321,19 +321,20 @@ export function execute_reaction_fn(reaction) {
* @returns {void} * @returns {void}
*/ */
function remove_reaction(signal, dependency) { function remove_reaction(signal, dependency) {
const reactions = dependency.reactions; var reactions = dependency.reactions;
let reactions_length = 0; var reactions_length = 0;
if (reactions !== null) { if (reactions !== null) {
reactions_length = reactions.length - 1; reactions_length = reactions.length - 1;
const index = reactions.indexOf(signal);
if (index !== -1) { if (reactions_length === 0) {
if (reactions_length === 0) { dependency.reactions = null;
dependency.reactions = null; } else {
} else { // Swap with last element and then remove.
// Swap with last element and then remove. var index = reactions.indexOf(signal);
reactions[index] = reactions[reactions_length];
reactions.pop(); reactions[index] = reactions[reactions_length];
} reactions.pop();
} }
} }

Loading…
Cancel
Save