Do no use the ahash reimport (#4504)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

Related to #3482 

Not sure what the "best practice" is, to me it seems like one should
import from "the original location" if possible, but now it should at
least be possible to not re-export ahash without any breakage in the
egui code base (but possibly in projects using egui, so one should
probably deprecate it if one would like to go that path). It also seems
like epaint re-exports ahash.
This commit is contained in:
Oscar Gustafsson 2024-05-27 16:24:50 +02:00 committed by GitHub
parent f0cbb18943
commit cd45d18615
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 34 additions and 20 deletions

View File

@ -1172,6 +1172,7 @@ dependencies = [
name = "eframe"
version = "0.27.2"
dependencies = [
"ahash",
"bytemuck",
"directories-next",
"document-features",
@ -1227,6 +1228,7 @@ dependencies = [
name = "egui-wgpu"
version = "0.27.2"
dependencies = [
"ahash",
"bytemuck",
"document-features",
"egui",
@ -1245,6 +1247,7 @@ name = "egui-winit"
version = "0.27.2"
dependencies = [
"accesskit_winit",
"ahash",
"arboard",
"document-features",
"egui",
@ -1302,6 +1305,7 @@ dependencies = [
name = "egui_extras"
version = "0.27.2"
dependencies = [
"ahash",
"chrono",
"document-features",
"egui",
@ -1320,6 +1324,7 @@ dependencies = [
name = "egui_glow"
version = "0.27.2"
dependencies = [
"ahash",
"bytemuck",
"document-features",
"egui",
@ -1340,6 +1345,7 @@ dependencies = [
name = "egui_plot"
version = "0.27.2"
dependencies = [
"ahash",
"document-features",
"egui",
"serde",

View File

@ -129,6 +129,7 @@ egui = { workspace = true, default-features = false, features = [
"log",
] }
ahash.workspace = true
document-features.workspace = true
log.workspace = true
parking_lot.workspace = true

View File

@ -26,10 +26,10 @@ use winit::{
window::{Window, WindowId},
};
use ahash::{HashMap, HashSet};
use egui::{
ahash::HashSet, epaint::ahash::HashMap, DeferredViewportUiCallback, ImmediateViewport,
ViewportBuilder, ViewportClass, ViewportId, ViewportIdMap, ViewportIdPair, ViewportInfo,
ViewportOutput,
DeferredViewportUiCallback, ImmediateViewport, ViewportBuilder, ViewportClass, ViewportId,
ViewportIdMap, ViewportIdPair, ViewportInfo, ViewportOutput,
};
#[cfg(feature = "accesskit")]
use egui_winit::accesskit_winit;

View File

@ -2,7 +2,7 @@ use std::{cell::RefCell, time::Instant};
use winit::event_loop::{EventLoop, EventLoopBuilder};
use egui::epaint::ahash::HashMap;
use ahash::HashMap;
use crate::{
epi,

View File

@ -15,8 +15,8 @@ use winit::{
window::{Window, WindowId},
};
use ahash::{HashMap, HashSet, HashSetExt};
use egui::{
ahash::{HashMap, HashSet, HashSetExt},
DeferredViewportUiCallback, FullOutput, ImmediateViewport, ViewportBuilder, ViewportClass,
ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportInfo, ViewportOutput,
};

View File

@ -50,6 +50,7 @@ x11 = ["winit?/x11"]
egui = { workspace = true, default-features = false }
epaint = { workspace = true, default-features = false, features = ["bytemuck"] }
ahash.workspace = true
bytemuck.workspace = true
document-features.workspace = true
log.workspace = true

View File

@ -2,7 +2,8 @@
use std::{borrow::Cow, num::NonZeroU64, ops::Range};
use epaint::{ahash::HashMap, emath::NumExt, PaintCallbackInfo, Primitive, Vertex};
use ahash::HashMap;
use epaint::{emath::NumExt, PaintCallbackInfo, Primitive, Vertex};
use wgpu::util::DeviceExt as _;

View File

@ -59,6 +59,8 @@ x11 = ["winit/x11", "bytemuck"]
[dependencies]
egui = { workspace = true, default-features = false, features = ["log"] }
ahash.workspace = true
log.workspace = true
raw-window-handle.workspace = true
web-time.workspace = true

View File

@ -14,9 +14,7 @@ pub use accesskit_winit;
pub use egui;
#[cfg(feature = "accesskit")]
use egui::accesskit;
use egui::{
ahash::HashSet, Pos2, Rect, Vec2, ViewportBuilder, ViewportCommand, ViewportId, ViewportInfo,
};
use egui::{Pos2, Rect, Vec2, ViewportBuilder, ViewportCommand, ViewportId, ViewportInfo};
pub use winit;
pub mod clipboard;
@ -24,6 +22,7 @@ mod window_settings;
pub use window_settings::WindowSettings;
use ahash::HashSet;
use raw_window_handle::HasDisplayHandle;
#[allow(unused_imports)]

View File

@ -52,13 +52,13 @@ impl Id {
/// Generate a new [`Id`] by hashing some source (e.g. a string or integer).
pub fn new(source: impl std::hash::Hash) -> Self {
Self::from_hash(epaint::ahash::RandomState::with_seeds(1, 2, 3, 4).hash_one(source))
Self::from_hash(ahash::RandomState::with_seeds(1, 2, 3, 4).hash_one(source))
}
/// Generate a new [`Id`] by hashing the parent [`Id`] and the given argument.
pub fn with(self, child: impl std::hash::Hash) -> Self {
use std::hash::{BuildHasher, Hasher};
let mut hasher = epaint::ahash::RandomState::with_seeds(1, 2, 3, 4).build_hasher();
let mut hasher = ahash::RandomState::with_seeds(1, 2, 3, 4).build_hasher();
hasher.write_u64(self.0.get());
child.hash(&mut hasher);
Self::from_hash(hasher.finish())

View File

@ -64,6 +64,7 @@ syntect = ["dep:syntect"]
[dependencies]
egui = { workspace = true, default-features = false, features = ["serde"] }
ahash.workspace = true
enum-map = { version = "2", features = ["serde"] }
log.workspace = true
serde.workspace = true

View File

@ -1,5 +1,5 @@
use ahash::HashMap;
use egui::{
ahash::HashMap,
load::{Bytes, BytesLoadResult, BytesLoader, BytesPoll, LoadError},
mutex::Mutex,
};

View File

@ -1,5 +1,5 @@
use ahash::HashMap;
use egui::{
ahash::HashMap,
load::{Bytes, BytesLoadResult, BytesLoader, BytesPoll, LoadError},
mutex::Mutex,
};

View File

@ -1,5 +1,5 @@
use ahash::HashMap;
use egui::{
ahash::HashMap,
load::{BytesPoll, ImageLoadResult, ImageLoader, ImagePoll, LoadError, SizeHint},
mutex::Mutex,
ColorImage,

View File

@ -1,7 +1,8 @@
use std::{mem::size_of, path::Path, sync::Arc};
use ahash::HashMap;
use egui::{
ahash::HashMap,
load::{BytesPoll, ImageLoadResult, ImageLoader, ImagePoll, LoadError, SizeHint},
mutex::Mutex,
ColorImage,

View File

@ -56,6 +56,7 @@ x11 = ["winit?/x11"]
egui = { workspace = true, default-features = false, features = ["bytemuck"] }
egui-winit = { workspace = true, optional = true, default-features = false }
ahash.workspace = true
bytemuck.workspace = true
glow.workspace = true
log.workspace = true

View File

@ -1,8 +1,8 @@
use ahash::HashSet;
use egui::{ViewportId, ViewportOutput};
pub use egui_winit;
pub use egui_winit::EventResponse;
use egui::{ahash::HashSet, ViewportId, ViewportOutput};
use egui_winit::winit;
pub use egui_winit::EventResponse;
use crate::shader_version::ShaderVersion;

View File

@ -37,6 +37,7 @@ serde = ["dep:serde", "egui/serde"]
[dependencies]
egui = { workspace = true, default-features = false }
ahash.workspace = true
#! ### Optional dependencies
## Enable this when generating docs.

View File

@ -15,7 +15,7 @@ mod transform;
use std::{cmp::Ordering, ops::RangeInclusive, sync::Arc};
use egui::ahash::HashMap;
use ahash::HashMap;
use egui::*;
use emath::Float as _;
use epaint::Hsva;

View File

@ -1,6 +1,6 @@
use std::collections::BTreeMap;
use egui::{ahash, Context, Id, Pos2, Vec2b};
use egui::{Context, Id, Pos2, Vec2b};
use crate::{PlotBounds, PlotTransform};