Skip to content

Commit

Permalink
cache stride for unchacked getters
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnze committed May 11, 2023
1 parent 8b95cc0 commit 3932da7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "micro_ndarray"
version = "0.2.4"
version = "0.2.5"
edition = "2021"
repository = "https://github.com/tudbut/micro_ndarray"
license = "MIT"
Expand Down
8 changes: 2 additions & 6 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ impl<'a, T, const D: usize> Array<T, D> {
real_loc += dim;
continue;
}
for s in &self.size[0..i] {
dim *= s;
}
dim *= self.stride[i];
real_loc += dim;
}
self.data.get_unchecked(real_loc)
Expand Down Expand Up @@ -177,9 +175,7 @@ impl<'a, T, const D: usize> Array<T, D> {
real_loc += dim;
continue;
}
for s in &self.size[0..i] {
dim *= s;
}
dim *= self.stride[i];
real_loc += dim;
}
self.data.get_unchecked_mut(real_loc)
Expand Down

0 comments on commit 3932da7

Please sign in to comment.