mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-30 21:30:03 -04:00
Change the way that events are represented.
The bulk of this commit is changing instances of Vec to RingBuf which is optimized for the push_back() / pop_front() strategy that is used internaly in the event system. The glutin custom iterators are now just wrappers around the RingBuf iterator type. This will bring the running time of iterator traversal from O(n^2) to O(n) because shifting-on-delete won't be performed.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
use std::{ptr};
|
||||
use std::ptr;
|
||||
use std::collections::RingBuf;
|
||||
use super::super::ffi;
|
||||
use super::ensure_thread_init;
|
||||
|
||||
pub struct MonitorID(pub uint);
|
||||
|
||||
pub fn get_available_monitors() -> Vec<MonitorID> {
|
||||
pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
||||
ensure_thread_init();
|
||||
let nb_monitors = unsafe {
|
||||
let display = ffi::XOpenDisplay(ptr::null());
|
||||
@@ -16,9 +17,9 @@ pub fn get_available_monitors() -> Vec<MonitorID> {
|
||||
nb_monitors
|
||||
};
|
||||
|
||||
let mut vec = Vec::new();
|
||||
vec.grow_fn(nb_monitors as uint, |i| MonitorID(i));
|
||||
vec
|
||||
let mut monitors = RingBuf::new();
|
||||
monitors.extend(range(0, nb_monitors).map(|i| MonitorID(i as uint)));
|
||||
monitors
|
||||
}
|
||||
|
||||
pub fn get_primary_monitor() -> MonitorID {
|
||||
|
||||
Reference in New Issue
Block a user