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:
Ty Overby 2015-01-01 23:09:16 -08:00
parent f68bf85a85
commit a698146943
8 changed files with 77 additions and 65 deletions

View file

@ -1,9 +1,10 @@
use core_graphics::display;
use std::collections::RingBuf;
pub struct MonitorID(u32);
pub fn get_available_monitors() -> Vec<MonitorID> {
let mut monitors = Vec::new();
let mut monitors = RingBuf::new();
unsafe {
let max_displays = 10u32;
let mut active_displays = [0u32, ..10];
@ -12,7 +13,7 @@ pub fn get_available_monitors() -> Vec<MonitorID> {
&mut active_displays[0],
&mut display_count);
for i in range(0u, display_count as uint) {
monitors.push(MonitorID(active_displays[i]));
monitors.push_back(MonitorID(active_displays[i]));
}
}
monitors