Merge pull request #789 from mahkoh/jorth/optimize-expose-change
globals: optimize expose_new_singletons
This commit is contained in:
commit
00f68e9484
1 changed files with 12 additions and 5 deletions
|
|
@ -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();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue