1
0
Fork 0
forked from wry/wry

Merge pull request #789 from mahkoh/jorth/optimize-expose-change

globals: optimize expose_new_singletons
This commit is contained in:
mahkoh 2026-03-11 14:21:10 +01:00 committed by GitHub
commit 00f68e9484
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -83,6 +83,7 @@ use {
arrayvec::ArrayVec, arrayvec::ArrayVec,
linearize::{Linearize, StaticMap}, linearize::{Linearize, StaticMap},
std::{ std::{
cell::Cell,
error::Error, error::Error,
fmt::{Display, Formatter}, fmt::{Display, Formatter},
rc::Rc, rc::Rc,
@ -256,6 +257,7 @@ pub struct Globals {
pub outputs: CopyHashMap<GlobalName, Rc<WlOutputGlobal>>, pub outputs: CopyHashMap<GlobalName, Rc<WlOutputGlobal>>,
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>, pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
singletons: StaticMap<Singleton, GlobalName>, singletons: StaticMap<Singleton, GlobalName>,
exposed: StaticMap<Singleton, Cell<bool>>,
} }
impl Globals { impl Globals {
@ -267,6 +269,7 @@ impl Globals {
outputs: Default::default(), outputs: Default::default(),
seats: Default::default(), seats: Default::default(),
singletons: StaticMap::from_fn(|_| GlobalName(0)), singletons: StaticMap::from_fn(|_| GlobalName(0)),
exposed: Default::default(),
}; };
add_singletons(&mut slf); add_singletons(&mut slf);
slf slf
@ -407,13 +410,17 @@ impl Globals {
pub fn expose_new_singletons(&self, state: &State) { pub fn expose_new_singletons(&self, state: &State) {
let mut singletons = ArrayVec::<_, { Singleton::LENGTH }>::new(); let mut singletons = ArrayVec::<_, { Singleton::LENGTH }>::new();
for name in self.singletons.values() { for (singleton, name) in self.singletons.iter() {
if let Some(global) = self.registry.get(name) if let Some(global) = self.registry.get(name) {
&& global.exposed(state) let exposed = global.exposed(state);
{ if self.exposed[singleton].replace(exposed) != exposed && exposed {
singletons.push(global); singletons.push(global);
}
} }
} }
if singletons.is_empty() {
return;
}
for client in state.clients.clients.borrow().values() { for client in state.clients.clients.borrow().values() {
let client = &client.data; let client = &client.data;
let caps = client.effective_caps.get(); let caps = client.effective_caps.get();