Skip to content

Commit

Permalink
simplify std::mem references
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminBrienen committed Sep 19, 2024
1 parent 612897b commit 1ee73a9
Show file tree
Hide file tree
Showing 19 changed files with 12 additions and 23 deletions.
2 changes: 0 additions & 2 deletions benches/benches/bevy_ecs/world/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::mem::size_of;

use bevy_ecs::{
component::Component,
entity::Entity,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ impl Termination for AppExit {

#[cfg(test)]
mod tests {
use std::{iter, marker::PhantomData, mem::size_of, sync::Mutex};
use std::{iter, marker::PhantomData, sync::Mutex};

use bevy_ecs::{
change_detection::{DetectChanges, ResMut},
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_asset/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use futures_io::{AsyncRead, AsyncSeek, AsyncWrite};
use futures_lite::{ready, Stream};
use std::{
io::SeekFrom,
mem::size_of,
path::{Path, PathBuf},
pin::Pin,
sync::Arc,
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,6 @@ impl EntityLocation {
#[cfg(test)]
mod tests {
use super::*;
use std::mem::size_of;

#[test]
fn entity_niche_optimization() {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/storage/blob_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ mod tests {
use crate::{component::Component, ptr::OwningPtr, world::World};

use super::BlobVec;
use std::{alloc::Layout, cell::RefCell, mem::align_of, rc::Rc};
use std::{alloc::Layout, cell::RefCell, rc::Rc};

/// # Safety
///
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2502,7 +2502,7 @@ impl World {
/// total += info.layout().size();
/// }
/// println!("Total size: {} bytes", total);
/// # assert_eq!(total, std::mem::size_of::<A>() + std::mem::size_of::<B>());
/// # assert_eq!(total, size_of::<A>() + size_of::<B>());
/// ```
///
/// ## Dynamically running closures for resources matching specific `TypeId`s
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bevy_render::{
renderer::{RenderDevice, RenderQueue},
};
use bevy_utils::HashMap;
use std::{mem::size_of, ops::Range, sync::Arc};
use std::{ops::Range, sync::Arc};

/// Manages uploading [`MeshletMesh`] asset data to the GPU.
#[derive(Resource)]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/meshlet/persistent_buffer_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{
asset::{Meshlet, MeshletBoundingSpheres},
persistent_buffer::PersistentGpuBufferable,
};
use std::{mem::size_of, sync::Arc};
use std::sync::Arc;

const MESHLET_VERTEX_SIZE_IN_BYTES: u32 = 48;

Expand Down
1 change: 0 additions & 1 deletion crates/bevy_pbr/src/meshlet/resource_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use binding_types::*;
use encase::internal::WriteInto;
use std::{
array, iter,
mem::size_of,
sync::{atomic::AtomicBool, Arc},
};

Expand Down
1 change: 0 additions & 1 deletion crates/bevy_pbr/src/render/mesh_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use bevy_math::Mat4;
use bevy_render::{
mesh::morph::MAX_MORPH_WEIGHTS, render_resource::*, renderer::RenderDevice, texture::GpuImage,
};
use std::mem::size_of;

use crate::render::skin::MAX_JOINTS;

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/morph.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{iter, mem, mem::size_of};
use std::{iter, mem};

use bevy_ecs::entity::EntityHashMap;
use bevy_ecs::prelude::*;
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_ptr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ trait DebugEnsureAligned {
impl<T: Sized> DebugEnsureAligned for *mut T {
#[track_caller]
fn debug_ensure_aligned(self) -> Self {
use core::mem::align_of;
let align = align_of::<T>();
// Implementation shamelessly borrowed from the currently unstable
// ptr.is_aligned_to.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/mesh/morph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use bevy_hierarchy::Children;
use bevy_math::Vec3;
use bevy_reflect::prelude::*;
use bytemuck::{Pod, Zeroable};
use std::{iter, mem::size_of};
use std::iter;
use thiserror::Error;

const MAX_TEXTURE_WIDTH: u32 = 2048;
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_render/src/render_resource/buffer_vec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{iter, marker::PhantomData, mem::size_of};
use std::{iter, marker::PhantomData};

use crate::{
render_resource::Buffer,
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<T: NoUninit> RawBufferVec<T> {
}

/// Creates a [`Buffer`] on the [`RenderDevice`] with size
/// at least `std::mem::size_of::<T>() * capacity`, unless a such a buffer already exists.
/// at least `size_of::<T>() * capacity`, unless a such a buffer already exists.
///
/// If a [`Buffer`] exists, but is too small, references to it will be discarded,
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s
Expand Down Expand Up @@ -302,7 +302,7 @@ where
}

/// Creates a [`Buffer`] on the [`RenderDevice`] with size
/// at least `std::mem::size_of::<T>() * capacity`, unless such a buffer already exists.
/// at least `size_of::<T>() * capacity`, unless such a buffer already exists.
///
/// If a [`Buffer`] exists, but is too small, references to it will be discarded,
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_render/src/view/visibility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ mod test {
use super::*;
use bevy_app::prelude::*;
use bevy_hierarchy::BuildChildren;
use std::mem::size_of;

fn visibility_bundle(visibility: Visibility) -> VisibilityBundle {
VisibilityBundle {
Expand Down
4 changes: 2 additions & 2 deletions examples/ecs/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This example show how you can create components dynamically, spawn entities with those components
//! as well as query for entities with those components.

use std::{alloc::Layout, io::Write, mem::size_of, ptr::NonNull};
use std::{alloc::Layout, io::Write, ptr::NonNull};

use bevy::prelude::*;
use bevy::{
Expand Down Expand Up @@ -41,7 +41,7 @@ query, q Query for entities
Accesses: 'A' with, '&A' read, '&mut A' write
Operators: '||' or, ',' and, '?' optional
e.g. &A || &B, &mut C, D, ?E";

fn main() {
Expand Down
1 change: 0 additions & 1 deletion examples/shader/custom_phase_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use bevy::{
},
};
use bytemuck::{Pod, Zeroable};
use std::mem::size_of;

/// A marker component that represents an entity that is to be rendered using
/// our custom phase item.
Expand Down
1 change: 0 additions & 1 deletion examples/shader/gpu_readback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use bevy::{
},
};
use crossbeam_channel::{Receiver, Sender};
use std::mem::size_of;

/// This example uses a shader source file from the assets subdirectory
const SHADER_ASSET_PATH: &str = "shaders/gpu_readback.wgsl";
Expand Down
1 change: 0 additions & 1 deletion examples/shader/shader_instancing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use bevy::{
},
};
use bytemuck::{Pod, Zeroable};
use std::mem::size_of;

/// This example uses a shader source file from the assets subdirectory
const SHADER_ASSET_PATH: &str = "shaders/instancing.wgsl";
Expand Down

0 comments on commit 1ee73a9

Please sign in to comment.