mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-25 04:54:07 +00:00
Switch to BTreeMap in project to make iteration order deterministic
This commit is contained in:
parent
80a8e0e985
commit
ec12ec25f6
2 changed files with 10 additions and 10 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet, BTreeMap},
|
||||||
fmt,
|
fmt,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io,
|
io,
|
||||||
|
|
@ -128,7 +128,7 @@ fn serialize_unresolved_map<S>(value: &HashMap<String, UnresolvedRbxValue>, seri
|
||||||
/// Similar to SourceProject, the structure of nodes in the project tree is
|
/// Similar to SourceProject, the structure of nodes in the project tree is
|
||||||
/// slightly different on-disk than how we want to handle them in the rest of
|
/// slightly different on-disk than how we want to handle them in the rest of
|
||||||
/// Rojo.
|
/// Rojo.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
struct SourceProjectNode {
|
struct SourceProjectNode {
|
||||||
#[serde(rename = "$className", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "$className", skip_serializing_if = "Option::is_none")]
|
||||||
class_name: Option<String>,
|
class_name: Option<String>,
|
||||||
|
|
@ -148,14 +148,14 @@ struct SourceProjectNode {
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
children: HashMap<String, SourceProjectNode>,
|
children: BTreeMap<String, SourceProjectNode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SourceProjectNode {
|
impl SourceProjectNode {
|
||||||
/// Consumes the SourceProjectNode and turns it into a ProjectNode.
|
/// Consumes the SourceProjectNode and turns it into a ProjectNode.
|
||||||
pub fn into_project_node(mut self, project_file_location: &Path) -> ProjectNode {
|
pub fn into_project_node(self, project_file_location: &Path) -> ProjectNode {
|
||||||
let children = self.children.drain()
|
let children = self.children.iter()
|
||||||
.map(|(key, value)| (key, value.into_project_node(project_file_location)))
|
.map(|(key, value)| (key.clone(), value.clone().into_project_node(project_file_location)))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Make sure that paths are absolute, transforming them by adding the
|
// Make sure that paths are absolute, transforming them by adding the
|
||||||
|
|
@ -264,7 +264,7 @@ pub enum ProjectSaveError {
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
|
||||||
pub struct ProjectNode {
|
pub struct ProjectNode {
|
||||||
pub class_name: Option<String>,
|
pub class_name: Option<String>,
|
||||||
pub children: HashMap<String, ProjectNode>,
|
pub children: BTreeMap<String, ProjectNode>,
|
||||||
pub properties: HashMap<String, UnresolvedRbxValue>,
|
pub properties: HashMap<String, UnresolvedRbxValue>,
|
||||||
pub ignore_unknown_instances: Option<bool>,
|
pub ignore_unknown_instances: Option<bool>,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{HashMap, BTreeMap},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ fn single_partition_game() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut replicated_storage_children = HashMap::new();
|
let mut replicated_storage_children = BTreeMap::new();
|
||||||
replicated_storage_children.insert("Foo".to_string(), foo);
|
replicated_storage_children.insert("Foo".to_string(), foo);
|
||||||
|
|
||||||
let replicated_storage = ProjectNode {
|
let replicated_storage = ProjectNode {
|
||||||
|
|
@ -73,7 +73,7 @@ fn single_partition_game() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut root_children = HashMap::new();
|
let mut root_children = BTreeMap::new();
|
||||||
root_children.insert("ReplicatedStorage".to_string(), replicated_storage);
|
root_children.insert("ReplicatedStorage".to_string(), replicated_storage);
|
||||||
root_children.insert("HttpService".to_string(), http_service);
|
root_children.insert("HttpService".to_string(), http_service);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue