1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

use BTreeMap for ResourceTable (#2721)

This commit is contained in:
Bartek Iwańczuk 2019-08-04 15:35:03 +02:00 committed by Ryan Dahl
parent 52c13fb3ed
commit aaa7a3eac4

View file

@ -24,7 +24,7 @@ use futures::Sink;
use futures::Stream; use futures::Stream;
use hyper; use hyper;
use std; use std;
use std::collections::HashMap; use std::collections::BTreeMap;
use std::io::{Error, Read, Seek, SeekFrom, Write}; use std::io::{Error, Read, Seek, SeekFrom, Write};
use std::net::{Shutdown, SocketAddr}; use std::net::{Shutdown, SocketAddr};
use std::process::ExitStatus; use std::process::ExitStatus;
@ -41,7 +41,7 @@ pub type ResourceId = u32; // Sometimes referred to RID.
// These store Deno's file descriptors. These are not necessarily the operating // These store Deno's file descriptors. These are not necessarily the operating
// system ones. // system ones.
type ResourceTable = HashMap<ResourceId, Repr>; type ResourceTable = BTreeMap<ResourceId, Repr>;
#[cfg(not(windows))] #[cfg(not(windows))]
use std::os::unix::io::FromRawFd; use std::os::unix::io::FromRawFd;
@ -56,7 +56,7 @@ lazy_static! {
// Starts at 3 because stdio is [0-2]. // Starts at 3 because stdio is [0-2].
static ref NEXT_RID: AtomicUsize = AtomicUsize::new(3); static ref NEXT_RID: AtomicUsize = AtomicUsize::new(3);
static ref RESOURCE_TABLE: Mutex<ResourceTable> = Mutex::new({ static ref RESOURCE_TABLE: Mutex<ResourceTable> = Mutex::new({
let mut m = HashMap::new(); let mut m = BTreeMap::new();
// TODO Load these lazily during lookup? // TODO Load these lazily during lookup?
m.insert(0, Repr::Stdin(tokio::io::stdin())); m.insert(0, Repr::Stdin(tokio::io::stdin()));