Skip to content

Commit

Permalink
Remove unnecessary ordered-float (#1461)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk authored Mar 1, 2023
1 parent 8dc3e46 commit 92d08db
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 20 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion crates/re_data_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ document-features = "0.2"
itertools = "0.10"
nohash-hasher = "0.2"
once_cell = "1.15.0"
ordered-float = { version = "3.2", features = ["serde"] }
serde = { version = "1", features = ["derive", "rc"], optional = true }
thiserror = "1.0"

Expand Down
6 changes: 3 additions & 3 deletions crates/re_data_store/src/editable_auto_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[serde(bound = "T: serde::Serialize, for<'de2> T: serde::Deserialize<'de2>")]
pub enum EditableAutoValue<T>
where
T: std::fmt::Debug + Eq + PartialEq + Clone + Default + serde::Serialize,
T: std::fmt::Debug + Clone + Default + PartialEq + serde::Serialize,
for<'de2> T: serde::Deserialize<'de2>,
{
/// The user explicitly specified what they wanted
Expand All @@ -17,7 +17,7 @@ where

impl<T> Default for EditableAutoValue<T>
where
T: std::fmt::Debug + Eq + PartialEq + Clone + Default + serde::Serialize,
T: std::fmt::Debug + Clone + Default + PartialEq + serde::Serialize,
for<'de2> T: serde::Deserialize<'de2>,
{
fn default() -> Self {
Expand All @@ -27,7 +27,7 @@ where

impl<T> EditableAutoValue<T>
where
T: std::fmt::Debug + Eq + PartialEq + Clone + Default + serde::Serialize,
T: std::fmt::Debug + Clone + Default + PartialEq + serde::Serialize,
for<'de2> T: serde::Deserialize<'de2>,
{
pub fn is_auto(&self) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_store/src/entity_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl EntityPropertyMap {

// ----------------------------------------------------------------------------

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct EntityProperties {
Expand All @@ -42,7 +42,7 @@ pub struct EntityProperties {
/// Distance of the projection plane (frustum far plane).
///
/// Only applies to pinhole cameras when in a spatial view, using 3D navigation.
pub pinhole_image_plane_distance: EditableAutoValue<ordered_float::NotNan<f32>>,
pub pinhole_image_plane_distance: EditableAutoValue<f32>,
}

impl EntityProperties {
Expand Down
1 change: 0 additions & 1 deletion crates/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ macaw = { workspace = true, features = ["with_serde"] }
mint = "0.5"
ndarray = "0.15"
nohash-hasher = "0.2"
ordered-float = { version = "3.2", features = ["serde"] }
poll-promise = "0.2"
rand = { version = "0.8", features = ["small_rng"] }
rfd = "0.11"
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/misc/transform_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn transform_at(
// Images are spanned in their local x/y space.
// Center it and move it along z, scaling the further we move.
let props = entity_properties.get(entity_path);
let distance: f32 = props.pinhole_image_plane_distance.get().into_inner();
let distance = *props.pinhole_image_plane_distance.get();

let focal_length = pinhole.focal_length_in_pixels();
let focal_length = glam::vec2(focal_length.x(), focal_length.y());
Expand Down
7 changes: 2 additions & 5 deletions crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ fn entity_props_ui(
query_latest_single::<Transform>(&ctx.log_db.entity_db, entity_path, &query)
{
ui.label("Image plane distance");
let mut distance: f32 =
entity_props.pinhole_image_plane_distance.get().into_inner();
let mut distance = *entity_props.pinhole_image_plane_distance.get();
let speed = (distance * 0.05).at_least(0.01);
if ui
.add(
Expand All @@ -428,9 +427,7 @@ fn entity_props_ui(
.changed()
{
entity_props.pinhole_image_plane_distance =
EditableAutoValue::UserEdited(
ordered_float::NotNan::new(distance).unwrap(),
);
EditableAutoValue::UserEdited(distance);
}
ui.end_row();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl CamerasPart {
return;
};

let frustum_length: f32 = props.pinhole_image_plane_distance.get().into_inner();
let frustum_length = *props.pinhole_image_plane_distance.get();

scene.space_cameras.push(SpaceCamera3D {
entity_path: entity_path.clone(),
Expand Down
5 changes: 2 additions & 3 deletions crates/re_viewer/src/ui/view_spatial/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ impl ViewSpatialState {
.data_blueprints_individual()
.get(&entity_path);
if properties.pinhole_image_plane_distance.is_auto() {
properties.pinhole_image_plane_distance = EditableAutoValue::Auto(
ordered_float::NotNan::new(default_image_plane_distance).unwrap(),
);
properties.pinhole_image_plane_distance =
EditableAutoValue::Auto(default_image_plane_distance);
data_blueprint
.data_blueprints_individual()
.set(entity_path, properties);
Expand Down

1 comment on commit 92d08db

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: 92d08db Previous: 8dc3e46 Ratio
datastore/insert/batch/rects/insert 565590 ns/iter (± 3160) 546884 ns/iter (± 1797) 1.03
datastore/latest_at/batch/rects/query 1819 ns/iter (± 2) 1831 ns/iter (± 7) 0.99
datastore/latest_at/missing_components/primary 355 ns/iter (± 10) 356 ns/iter (± 1) 1.00
datastore/latest_at/missing_components/secondaries 424 ns/iter (± 2) 426 ns/iter (± 0) 1.00
datastore/range/batch/rects/query 153611 ns/iter (± 819) 155012 ns/iter (± 593) 0.99
mono_points_arrow/generate_message_bundles 46975075 ns/iter (± 1549554) 47762281 ns/iter (± 1312329) 0.98
mono_points_arrow/generate_messages 137348044 ns/iter (± 1515453) 138430517 ns/iter (± 1344508) 0.99
mono_points_arrow/encode_log_msg 163579271 ns/iter (± 619404) 165552042 ns/iter (± 559602) 0.99
mono_points_arrow/encode_total 354524564 ns/iter (± 2022974) 358603187 ns/iter (± 2325877) 0.99
mono_points_arrow/decode_log_msg 186203921 ns/iter (± 1173369) 187663885 ns/iter (± 1101542) 0.99
mono_points_arrow/decode_message_bundles 73494342 ns/iter (± 1656911) 74420508 ns/iter (± 1233925) 0.99
mono_points_arrow/decode_total 255436305 ns/iter (± 2076627) 256789361 ns/iter (± 1978684) 0.99
batch_points_arrow/generate_message_bundles 333800 ns/iter (± 629) 332935 ns/iter (± 2638) 1.00
batch_points_arrow/generate_messages 6166 ns/iter (± 55) 6274 ns/iter (± 27) 0.98
batch_points_arrow/encode_log_msg 360170 ns/iter (± 1521) 359501 ns/iter (± 1134) 1.00
batch_points_arrow/encode_total 716384 ns/iter (± 3348) 709109 ns/iter (± 2453) 1.01
batch_points_arrow/decode_log_msg 351143 ns/iter (± 1105) 346502 ns/iter (± 871) 1.01
batch_points_arrow/decode_message_bundles 2079 ns/iter (± 15) 2057 ns/iter (± 13) 1.01
batch_points_arrow/decode_total 352459 ns/iter (± 1490) 359068 ns/iter (± 1272) 0.98
arrow_mono_points/insert 7136331896 ns/iter (± 38966448) 7151725441 ns/iter (± 20536898) 1.00
arrow_mono_points/query 1687315 ns/iter (± 7694) 1709144 ns/iter (± 9761) 0.99
arrow_batch_points/insert 2700296 ns/iter (± 10304) 2616679 ns/iter (± 9551) 1.03
arrow_batch_points/query 17507 ns/iter (± 72) 17644 ns/iter (± 67) 0.99
tuid/Tuid::random 34 ns/iter (± 0) 34 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.