Skip to content

Commit f8631cc

Browse files
Remove connection_id from ViewContext (#3464)
# Description of Changes <!-- Please describe your change, mention any related tickets, and so on here. --> Removing `connection_id` from `ViewContext` for performance reasons. We intend to wait to hear from clients before assuming that it's necessary to include. # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> None (unreleased feature) # Expected complexity level and risk <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> 0 # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> n/a
1 parent ddfdde2 commit f8631cc

2 files changed

Lines changed: 1 addition & 22 deletions

File tree

crates/bindings/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@ pub struct AnonymousViewContext {
806806
/// Use this type if the view depends on the caller's identity.
807807
pub struct ViewContext {
808808
pub sender: Identity,
809-
pub connection_id: Option<ConnectionId>,
810809
pub db: LocalReadOnly,
811810
}
812811

@@ -943,7 +942,6 @@ impl ReducerContext {
943942
pub fn as_read_only(&self) -> ViewContext {
944943
ViewContext {
945944
sender: self.sender,
946-
connection_id: self.connection_id,
947945
db: LocalReadOnly {},
948946
}
949947
}

crates/bindings/src/rt.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,6 @@ extern "C" fn __call_view__(
807807
sender_1: u64,
808808
sender_2: u64,
809809
sender_3: u64,
810-
conn_id_0: u64,
811-
conn_id_1: u64,
812810
args: BytesSource,
813811
sink: BytesSink,
814812
) -> i16 {
@@ -817,29 +815,12 @@ extern "C" fn __call_view__(
817815
let sender: [u8; 32] = bytemuck::must_cast(sender);
818816
let sender = Identity::from_byte_array(sender); // The LITTLE-ENDIAN constructor.
819817

820-
// Piece together `conn_id_i` into a `ConnectionId`.
821-
// The all-zeros `ConnectionId` (`ConnectionId::ZERO`) is interpreted as `None`.
822-
let conn_id = [conn_id_0, conn_id_1];
823-
let conn_id: [u8; 16] = bytemuck::must_cast(conn_id);
824-
let conn_id = ConnectionId::from_le_byte_array(conn_id); // The LITTLE-ENDIAN constructor.
825-
let conn_id = (conn_id != ConnectionId::ZERO).then_some(conn_id);
826-
827818
let views = VIEWS.get().unwrap();
828819
let db = LocalReadOnly {};
829-
let connection_id = conn_id;
830820

831821
write_to_sink(
832822
sink,
833-
&with_read_args(args, |args| {
834-
views[id](
835-
ViewContext {
836-
sender,
837-
connection_id,
838-
db,
839-
},
840-
args,
841-
)
842-
}),
823+
&with_read_args(args, |args| views[id](ViewContext { sender, db }, args)),
843824
);
844825
0
845826
}

0 commit comments

Comments
 (0)