Skip to content

Commit

Permalink
Appease clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Sep 26, 2024
1 parent c354643 commit a6764be
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions modules/benchmarks/src/ia_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub fn update_position_all(ctx: &ReducerContext, expected: u32) {
pub fn update_position_with_velocity(ctx: &ReducerContext, expected: u32) {
let mut count = 0;
for velocity in ctx.db.velocity().iter() {
let Some(mut position) = ctx.db.position().entity_id().find(&velocity.entity_id) else {
let Some(mut position) = ctx.db.position().entity_id().find(velocity.entity_id) else {
continue;
};

Expand Down Expand Up @@ -274,7 +274,7 @@ fn get_targetables_near_quad(ctx: &ReducerContext, entity_id: u64, num_players:
ctx.db
.game_targetable_state()
.entity_id()
.find(&t.entity_id)
.find(t.entity_id)
.expect("Identity not found"),
)
}
Expand All @@ -296,7 +296,7 @@ fn move_agent(
.db
.game_enemy_state()
.entity_id()
.find(&entity_id)
.find(entity_id)
.expect("GameEnemyState Entity ID not found")
.clone();
ctx.db.game_enemy_state().entity_id().update(enemy);
Expand All @@ -314,7 +314,7 @@ fn move_agent(
.db
.game_targetable_state()
.entity_id()
.find(&entity_id)
.find(entity_id)
.expect("GameTargetableState Entity ID not found");
let new_hash = calculate_hash(&targetable.quad) as i64;
targetable.quad = new_hash;
Expand All @@ -326,7 +326,7 @@ fn move_agent(
.db
.game_live_targetable_state()
.entity_id()
.find(&entity_id)
.find(entity_id)
.is_some()
{
ctx.db
Expand All @@ -341,7 +341,7 @@ fn move_agent(
.db
.game_mobile_entity_state()
.entity_id()
.find(&entity_id)
.find(entity_id)
.expect("GameMobileEntityState Entity ID not found");
let mobile_entity = GameMobileEntityState {
entity_id,
Expand All @@ -367,20 +367,20 @@ fn agent_loop(
.db
.game_mobile_entity_state()
.entity_id()
.find(&entity_id)
.find(entity_id)
.expect("GameMobileEntityState Entity ID not found");

let agent_entity = ctx
.db
.game_enemy_state()
.entity_id()
.find(&entity_id)
.find(entity_id)
.expect("GameEnemyState Entity ID not found");
let agent_herd = ctx
.db
.game_herd_cache()
.id()
.find(&agent_entity.herd_id)
.find(agent_entity.herd_id)
.expect("GameHerdCache Entity ID not found");
let agent_herd_coordinates = agent_herd.location;

Expand All @@ -402,7 +402,7 @@ pub fn game_loop_enemy_ia(ctx: &ReducerContext, players: u64) {
.db
.game_targetable_state()
.entity_id()
.find(&agent.entity_id)
.find(agent.entity_id)
.expect("No TargetableState for AgentState entity");

let surrounding_agents = get_targetables_near_quad(ctx, agent_targetable.entity_id, players);
Expand Down
8 changes: 4 additions & 4 deletions modules/benchmarks/src/synthetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub fn iterate_unique_0_u32_u64_u64(ctx: &ReducerContext) {

#[spacetimedb::reducer]
pub fn filter_unique_0_u32_u64_str_by_id(ctx: &ReducerContext, id: u32) {
if let Some(p) = ctx.db.unique_0_u32_u64_str().id().find(&id) {
if let Some(p) = ctx.db.unique_0_u32_u64_str().id().find(id) {
black_box(p);
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ pub fn filter_btree_each_column_u32_u64_str_by_name(ctx: &ReducerContext, name:

#[spacetimedb::reducer]
pub fn filter_unique_0_u32_u64_u64_by_id(ctx: &ReducerContext, id: u32) {
if let Some(loc) = ctx.db.unique_0_u32_u64_u64().id().find(&id) {
if let Some(loc) = ctx.db.unique_0_u32_u64_u64().id().find(id) {
black_box(loc);
}
}
Expand Down Expand Up @@ -328,12 +328,12 @@ pub fn filter_btree_each_column_u32_u64_u64_by_y(ctx: &ReducerContext, x: u64) {

#[spacetimedb::reducer]
pub fn delete_unique_0_u32_u64_str_by_id(ctx: &ReducerContext, id: u32) {
ctx.db.unique_0_u32_u64_str().id().delete(&id);
ctx.db.unique_0_u32_u64_str().id().delete(id);
}

#[spacetimedb::reducer]
pub fn delete_unique_0_u32_u64_u64_by_id(ctx: &ReducerContext, id: u32) {
ctx.db.unique_0_u32_u64_u64().id().delete(&id);
ctx.db.unique_0_u32_u64_u64().id().delete(id);
}

// ---------- clear table ----------
Expand Down
2 changes: 1 addition & 1 deletion modules/perf-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CHUNK: u64 = ID / ROWS_PER_CHUNK;
/// Probing a single column index for a single row should be fast!
pub fn test_index_scan_on_id(ctx: &ReducerContext) {
let span = LogStopwatch::new("Index scan on {id}");
let location = ctx.db.location().id().find(&ID).unwrap();
let location = ctx.db.location().id().find(ID).unwrap();
span.end();
assert_eq!(ID, location.id);
}
Expand Down
6 changes: 3 additions & 3 deletions modules/quickstart-chat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn validate_name(name: String) -> Result<String, String> {
#[spacetimedb::reducer]
pub fn set_name(ctx: &ReducerContext, name: String) -> Result<(), String> {
let name = validate_name(name)?;
if let Some(user) = ctx.db.user().identity().find(&ctx.sender) {
if let Some(user) = ctx.db.user().identity().find(ctx.sender) {
ctx.db.user().identity().update(User {
name: Some(name),
..user
Expand Down Expand Up @@ -65,7 +65,7 @@ pub fn init(_ctx: &ReducerContext) {}

#[spacetimedb::reducer(client_connected)]
pub fn identity_connected(ctx: &ReducerContext) {
if let Some(user) = ctx.db.user().identity().find(&ctx.sender) {
if let Some(user) = ctx.db.user().identity().find(ctx.sender) {
// If this is a returning user, i.e. we already have a `User` with this `Identity`,
// set `online: true`, but leave `name` and `identity` unchanged.
ctx.db.user().identity().update(User { online: true, ..user });
Expand All @@ -82,7 +82,7 @@ pub fn identity_connected(ctx: &ReducerContext) {

#[spacetimedb::reducer(client_disconnected)]
pub fn identity_disconnected(ctx: &ReducerContext) {
if let Some(user) = ctx.db.user().identity().find(&ctx.sender) {
if let Some(user) = ctx.db.user().identity().find(ctx.sender) {
ctx.db.user().identity().update(User { online: false, ..user });
} else {
// This branch should be unreachable,
Expand Down

0 comments on commit a6764be

Please sign in to comment.