mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Replace all sort with unstable sort (#38427)
["When applicable, unstable sorting is preferred because it is generally faster than stable sorting and it doesn’t allocate auxiliary memory."](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.sort) Binary also reduced by 1KB in Release. Testing: No behaviour change as semantically all current usage does not have any pair with `std::cmp::Ordering::Equal`. Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
parent
7c70d811a6
commit
58425f6ae2
4 changed files with 4 additions and 4 deletions
|
@ -127,7 +127,7 @@ mod test {
|
||||||
webviews: &WebViewManager<WebView>,
|
webviews: &WebViewManager<WebView>,
|
||||||
) -> Vec<(WebViewId, WebView)> {
|
) -> Vec<(WebViewId, WebView)> {
|
||||||
let mut keys = webviews.webviews.keys().collect::<Vec<_>>();
|
let mut keys = webviews.webviews.keys().collect::<Vec<_>>();
|
||||||
keys.sort();
|
keys.sort_unstable();
|
||||||
keys.iter()
|
keys.iter()
|
||||||
.map(|&id| (*id, webviews.webviews.get(id).cloned().unwrap()))
|
.map(|&id| (*id, webviews.webviews.get(id).cloned().unwrap()))
|
||||||
.collect()
|
.collect()
|
||||||
|
|
|
@ -5401,7 +5401,7 @@ where
|
||||||
};
|
};
|
||||||
// In order to get repeatability, we sort the pipeline ids.
|
// In order to get repeatability, we sort the pipeline ids.
|
||||||
let mut pipeline_ids: Vec<&PipelineId> = self.pipelines.keys().collect();
|
let mut pipeline_ids: Vec<&PipelineId> = self.pipelines.keys().collect();
|
||||||
pipeline_ids.sort();
|
pipeline_ids.sort_unstable();
|
||||||
if let Some((ref mut rng, probability)) = self.random_pipeline_closure {
|
if let Some((ref mut rng, probability)) = self.random_pipeline_closure {
|
||||||
if let Some(pipeline_id) = pipeline_ids.choose(rng) {
|
if let Some(pipeline_id) = pipeline_ids.choose(rng) {
|
||||||
if let Some(pipeline) = self.pipelines.get(pipeline_id) {
|
if let Some(pipeline) = self.pipelines.get(pipeline_id) {
|
||||||
|
|
|
@ -99,7 +99,7 @@ mod test {
|
||||||
webviews: &WebViewManager<WebView>,
|
webviews: &WebViewManager<WebView>,
|
||||||
) -> Vec<(WebViewId, WebView)> {
|
) -> Vec<(WebViewId, WebView)> {
|
||||||
let mut keys = webviews.webviews.keys().collect::<Vec<_>>();
|
let mut keys = webviews.webviews.keys().collect::<Vec<_>>();
|
||||||
keys.sort();
|
keys.sort_unstable();
|
||||||
keys.iter()
|
keys.iter()
|
||||||
.map(|&id| {
|
.map(|&id| {
|
||||||
(
|
(
|
||||||
|
|
|
@ -814,7 +814,7 @@ fn load_userscripts(userscripts_directory: Option<&Path>) -> std::io::Result<Vec
|
||||||
let mut files = std::fs::read_dir(userscripts_directory)?
|
let mut files = std::fs::read_dir(userscripts_directory)?
|
||||||
.map(|e| e.map(|entry| entry.path()))
|
.map(|e| e.map(|entry| entry.path()))
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
files.sort();
|
files.sort_unstable();
|
||||||
for file in files {
|
for file in files {
|
||||||
userscripts.push(UserScript {
|
userscripts.push(UserScript {
|
||||||
script: std::fs::read_to_string(&file)?,
|
script: std::fs::read_to_string(&file)?,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue