remove some needless indirection (#10697)

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/10699/head
Rich Harris 10 months ago committed by GitHub
parent aa29a853dd
commit 0cc74e46fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -18,7 +18,7 @@ import { clear_text_content, empty, map_get, map_set } from '../../operations.js
import { insert, remove } from '../../reconciler.js';
import { current_block, destroy_signal, execute_effect, push_destroy_fn } from '../../runtime.js';
import { render_effect } from '../../reactivity/effects.js';
import { source, mutable_source, set_signal_value } from '../../reactivity/sources.js';
import { source, mutable_source, set } from '../../reactivity/sources.js';
import { trigger_transitions } from '../../transitions.js';
import { is_array } from '../../utils.js';
import { EACH_BLOCK, EACH_ITEM_BLOCK } from '../../constants.js';
@ -838,7 +838,7 @@ export function get_first_element(block) {
function update_each_item_block(block, item, index, type) {
const block_v = block.v;
if ((type & EACH_ITEM_REACTIVE) !== 0) {
set_signal_value(block_v, item);
set(block_v, item);
}
const transitions = block.s;
const index_is_reactive = (type & EACH_INDEX_REACTIVE) !== 0;
@ -848,7 +848,7 @@ function update_each_item_block(block, item, index, type) {
each_animation(block, transitions);
}
if (index_is_reactive) {
set_signal_value(/** @type {import('../../types.js').Signal<number>} */ (block.i), index);
set(/** @type {import('../../types.js').Signal<number>} */ (block.i), index);
} else {
block.i = index;
}

@ -18,7 +18,7 @@ import {
object_prototype
} from './utils.js';
import { add_owner, check_ownership, strip_owner } from './dev/ownership.js';
import { mutable_source, source, set, set_signal_value } from './reactivity/sources.js';
import { mutable_source, source, set } from './reactivity/sources.js';
import { STATE_SYMBOL, UNINITIALIZED } from './constants.js';
/**
@ -153,7 +153,7 @@ export function unstate(value) {
*/
function update_version(signal, d = 1) {
const value = untrack(() => get(signal));
set_signal_value(signal, value + d);
set(signal, value + d);
}
/** @type {ProxyHandler<import('./types.js').ProxyStateObject<any>>} */

@ -87,17 +87,6 @@ function create_source_signal(flags, value) {
};
}
/**
* @template V
* @param {import('./types.js').Signal<V>} signal
* @param {V} value
* @returns {V}
*/
export function set(signal, value) {
set_signal_value(signal, value);
return value;
}
/**
* @template V
* @param {import('./types.js').Signal<V>} signal
@ -114,7 +103,7 @@ export function set_sync(signal, value) {
* @param {V} value
*/
export function mutate(source, value) {
set_signal_value(
set(
source,
untrack(() => get(source))
);
@ -125,9 +114,9 @@ export function mutate(source, value) {
* @template V
* @param {import('./types.js').Signal<V>} signal
* @param {V} value
* @returns {void}
* @returns {V}
*/
export function set_signal_value(signal, value) {
export function set(signal, value) {
if (
!current_untracking &&
!ignore_mutation_validation &&
@ -191,4 +180,6 @@ export function set_signal_value(signal, value) {
}
}
}
return value;
}

@ -26,12 +26,11 @@ import {
DESTROYED,
INERT,
MANAGED,
SOURCE,
STATE_SYMBOL
} from './constants.js';
import { flush_tasks } from './dom/task.js';
import { add_owner } from './dev/ownership.js';
import { mutate, set_signal_value } from './reactivity/sources.js';
import { mutate, set } from './reactivity/sources.js';
const IS_EFFECT = EFFECT | PRE_EFFECT | RENDER_EFFECT;
@ -1111,7 +1110,7 @@ function get_parent_context(component_context) {
*/
export function update(signal, d = 1) {
const value = get(signal);
set_signal_value(signal, value + d);
set(signal, value + d);
return value;
}
@ -1122,7 +1121,7 @@ export function update(signal, d = 1) {
*/
export function update_pre(signal, d = 1) {
const value = get(signal) + d;
set_signal_value(signal, value);
set(signal, value);
return value;
}

Loading…
Cancel
Save