From a698146943bcd6df2a61bbfd56badf3018662709 Mon Sep 17 00:00:00 2001 From: Ty Overby Date: Thu, 1 Jan 2015 23:09:16 -0800 Subject: 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. --- src/osx/monitor.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/osx/monitor.rs') diff --git a/src/osx/monitor.rs b/src/osx/monitor.rs index 383fd32..3fb1d74 100644 --- a/src/osx/monitor.rs +++ b/src/osx/monitor.rs @@ -1,9 +1,10 @@ use core_graphics::display; +use std::collections::RingBuf; pub struct MonitorID(u32); pub fn get_available_monitors() -> Vec { - 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 { &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 -- cgit v1.2.3