aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32/monitor.rs
diff options
context:
space:
mode:
authorTy Overby <ty@pre-alpha.com>2015-01-01 23:09:16 -0800
committerTy Overby <ty@pre-alpha.com>2015-01-01 23:44:02 -0800
commita698146943bcd6df2a61bbfd56badf3018662709 (patch)
treeb2cc041b67dd54f64c6123981bffbd0201f9620a /src/win32/monitor.rs
parentf68bf85a85ceb416f714bc36ff5aa5c6ae65c008 (diff)
downloadglutin-a698146943bcd6df2a61bbfd56badf3018662709.tar.gz
glutin-a698146943bcd6df2a61bbfd56badf3018662709.zip
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.
Diffstat (limited to 'src/win32/monitor.rs')
-rw-r--r--src/win32/monitor.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/win32/monitor.rs b/src/win32/monitor.rs
index f841f1e..82ee02a 100644
--- a/src/win32/monitor.rs
+++ b/src/win32/monitor.rs
@@ -1,5 +1,7 @@
use winapi;
+use std::collections::RingBuf;
+
/// Win32 implementation of the main `MonitorID` object.
pub struct MonitorID {
/// The system name of the monitor.
@@ -22,11 +24,11 @@ pub struct MonitorID {
}
/// Win32 implementation of the main `get_available_monitors` function.
-pub fn get_available_monitors() -> Vec<MonitorID> {
+pub fn get_available_monitors() -> RingBuf<MonitorID> {
use std::{iter, mem, ptr};
// return value
- let mut result = Vec::new();
+ let mut result = RingBuf::new();
// enumerating the devices is done by querying device 0, then device 1, then device 2, etc.
// until the query function returns null
@@ -78,7 +80,7 @@ pub fn get_available_monitors() -> Vec<MonitorID> {
};
// adding to the resulting list
- result.push(MonitorID {
+ result.push_back(MonitorID {
name: output.DeviceName,
readable_name: readable_name,
flags: output.StateFlags,
@@ -123,7 +125,7 @@ impl MonitorID {
}
/// This is a Win32-only function for `MonitorID` that returns the position of the
- /// monitor on the desktop.
+ /// monitor on the desktop.
/// A window that is positionned at these coordinates will overlap the monitor.
pub fn get_position(&self) -> (uint, uint) {
self.position