Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libtime::Tm::to_utc() is slow even if already utc #66

Closed
steveklabnik opened this issue Jan 29, 2015 · 1 comment · Fixed by #87
Closed

libtime::Tm::to_utc() is slow even if already utc #66

steveklabnik opened this issue Jan 29, 2015 · 1 comment · Fixed by #87

Comments

@steveklabnik
Copy link

Issue by seanmonstar
Friday Nov 07, 2014 at 01:29 GMT

For earlier discussion, see rust-lang/rust#18725

This issue was labelled with: in the Rust repository


Tm.to_utc() calls out to the runtime fn rust_timegm twice, once to convert to a Timespec, and a second time to convert the timespec to a new Tm with offset of 0. If a Tm is already UTC, this should skip both those calls.

@zslayton
Copy link

Is this as simple as:

    /// Convert time to the UTC
    pub fn to_utc(&self) -> Tm {
        match self.tm_utcoff {
          0 => *self,
          _ => at_utc(self.to_timespec())
        }
    }

? If so, I'd be happy to put together a pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants