diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-10 20:16:32 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-10 20:16:32 +0100 |
commit | ca9a5dd1654cc0d54ed5b2bb71ec8ed559470276 (patch) | |
tree | bba0a2507861fd9c4e354283e2b2102532747e7e /crates/stdx | |
parent | 773bb5173d3d54e6d19dfadd75c342c7acdce287 (diff) | |
parent | 1b68c72fe93424213db895a4066eafb99dfdeac9 (diff) |
Merge #3933
3933: Fix accidently quadratic behavior when processing include! r=matklad a=matklad
This fixes the immediate problem behind #3927. It doesn't yet fix the deeper problem with `to_node` being quadratic (hence the test is ignored), but it is a good start anyway.
bors r+
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/stdx')
-rw-r--r-- | crates/stdx/src/lib.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 401a568bd..01cdf452c 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! Missing batteries for standard libraries. | 1 | //! Missing batteries for standard libraries. |
2 | 2 | ||
3 | use std::{cell::Cell, fmt}; | 3 | use std::{cell::Cell, fmt, time::Instant}; |
4 | 4 | ||
5 | #[inline(always)] | 5 | #[inline(always)] |
6 | pub fn is_ci() -> bool { | 6 | pub fn is_ci() -> bool { |
@@ -88,3 +88,17 @@ where | |||
88 | Ok(()) | 88 | Ok(()) |
89 | } | 89 | } |
90 | } | 90 | } |
91 | pub fn timeit(label: &'static str) -> impl Drop { | ||
92 | struct Guard { | ||
93 | label: &'static str, | ||
94 | start: Instant, | ||
95 | } | ||
96 | |||
97 | impl Drop for Guard { | ||
98 | fn drop(&mut self) { | ||
99 | eprintln!("{}: {:?}", self.label, self.start.elapsed()) | ||
100 | } | ||
101 | } | ||
102 | |||
103 | Guard { label, start: Instant::now() } | ||
104 | } | ||