Replace time with std::time in components/gfx (#31168)

* Replace time with std::time in components/gfx

Signed-off-by: devjos <github_11837948@feido.de>

* Remove time dependency in components/gfx/Cargo.toml

Signed-off-by: devjos <github_11837948@feido.de>

---------

Signed-off-by: devjos <github_11837948@feido.de>
This commit is contained in:
Johannes S 2024-01-25 09:31:40 +01:00 committed by GitHub
parent af6652fc09
commit 886f6c58d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 6 deletions

1
Cargo.lock generated
View file

@ -2065,7 +2065,6 @@ dependencies = [
"servo_url", "servo_url",
"smallvec", "smallvec",
"style", "style",
"time 0.1.45",
"truetype", "truetype",
"ucd", "ucd",
"unicode-bidi", "unicode-bidi",

View file

@ -34,7 +34,6 @@ servo_atoms = { path = "../atoms" }
servo_url = { path = "../url" } servo_url = { path = "../url" }
smallvec = { workspace = true, features = ["union"] } smallvec = { workspace = true, features = ["union"] }
style = { path = "../style", features = ["servo"] } style = { path = "../style", features = ["servo"] }
time = { workspace = true }
ucd = "0.1.1" ucd = "0.1.1"
unicode-bidi = { workspace = true, features = ["with_serde"] } unicode-bidi = { workspace = true, features = ["with_serde"] }
unicode-script = { workspace = true } unicode-script = { workspace = true }

View file

@ -8,6 +8,7 @@ use std::collections::HashMap;
use std::rc::Rc; use std::rc::Rc;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc; use std::sync::Arc;
use std::time::Instant;
use std::{iter, str}; use std::{iter, str};
use app_units::Au; use app_units::Au;
@ -253,7 +254,7 @@ impl Font {
.borrow_mut() .borrow_mut()
.entry(lookup_key) .entry(lookup_key)
.or_insert_with(|| { .or_insert_with(|| {
let start_time = time::precise_time_ns(); let start_time = Instant::now();
let mut glyphs = GlyphStore::new( let mut glyphs = GlyphStore::new(
text.len(), text.len(),
options options
@ -276,9 +277,11 @@ impl Font {
.shape_text(text, options, &mut glyphs); .shape_text(text, options, &mut glyphs);
} }
let end_time = time::precise_time_ns(); let end_time = Instant::now();
TEXT_SHAPING_PERFORMANCE_COUNTER TEXT_SHAPING_PERFORMANCE_COUNTER.fetch_add(
.fetch_add((end_time - start_time) as usize, Ordering::Relaxed); (end_time.duration_since(start_time).as_nanos()) as usize,
Ordering::Relaxed,
);
Arc::new(glyphs) Arc::new(glyphs)
}) })
.clone(); .clone();