util: Don't throw in GetTime{Millis,Micros}(). Mark as noexcept. #13382

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:dont-throw-in-GetTimeMillis-and-GetTimeMicros changing 2 files +8 −6
  1. practicalswift commented at 5:23 PM on June 3, 2018: contributor
    • boost::posix_time::ptime(boost::gregorian::date(1970,1,1) throws bad_year, bad_day_of_month, or bad_day_month (derivatives of std::out_of_range) if the year, month or day are out of range. It is obvious to us that it won't throw at run-time for 1970-01-01, but that is not obvious for the compiler or static analyzers. From a static analyzer perspective it will look like these exceptions can reach all the way up to NodeImpl::appInitMain() where they are unhandled.
    • boost::posix_time::from_time_t(0) is simpler and doesn't throw.
    • Re-use the result of boost::posix_time::from_time_t(0) like we're doing in DecodeDumpTime(…).
    • Mark GetTimeMillis() and GetTimeMicros() as noexcept.
  2. qmma70 commented at 11:48 PM on June 3, 2018: contributor

    Why not use std::chrono::high_resolution_clock?

  3. practicalswift commented at 8:42 PM on June 14, 2018: contributor

    @qmma70 I'm all for removing Boost, but that is something for another PR :-)

  4. sipa commented at 11:31 PM on June 14, 2018: member

    utACK bcdf285db285932365fe6cae17ba5a585cd1a17e

  5. fanquake requested review from theuni on Jun 17, 2018
  6. fanquake added the label Utils/log/libs on Jul 1, 2018
  7. DrahtBot commented at 3:16 PM on July 29, 2018: contributor

    <!--5d09a71f8925f3f132321140b44b946d-->The last travis run for this pull request was 55 days ago and is thus outdated. To trigger a fresh travis build, this pull request should be closed and re-opened.

  8. DrahtBot closed this on Jul 29, 2018

  9. DrahtBot reopened this on Jul 29, 2018

  10. Empact commented at 5:35 PM on August 11, 2018: member
  11. sipa commented at 5:39 PM on August 11, 2018: member

    @Empact What in particular is an argument against noexcept here?

  12. Empact commented at 11:10 PM on August 11, 2018: member

    I guess I'm more wondering: what is the justification for it? If it doesn't help with significant performance optimizations (ala move) and we don't expect it to affect the error performance of the method (because we don't expect it to throw) then why should we apply the treatment? If we should apply it here, should we apply it to most methods? Just a notion.

  13. practicalswift cross-referenced this on Aug 31, 2018 from issue wallet: Remove unused local variable old_label by practicalswift
  14. practicalswift commented at 2:10 PM on October 7, 2018: contributor

    @Empact Scott Meyers has this to say about noexcept: http://aristeia.com/EC++11-14/noexcept%202014-03-31.pdf – "Declare noexcept whenever possible" :-)

  15. DrahtBot cross-referenced this on Oct 20, 2018 from issue refactor: Drop boost::thread and boost::chrono by ken2812221
  16. DrahtBot commented at 10:59 AM on October 20, 2018: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  17. DrahtBot added the label Needs rebase on Nov 5, 2018
  18. Don't throw in GetTime{Millis,Micros}(). Mark as noexcept. afc97c731e
  19. practicalswift force-pushed on Nov 5, 2018
  20. DrahtBot removed the label Needs rebase on Nov 5, 2018
  21. ken2812221 commented at 7:14 AM on December 2, 2018: contributor

    utACK afc97c731e407f87fae0385aa5c3a729981ca1aa

  22. MarcoFalke commented at 8:02 PM on December 3, 2018: member

    Looks like this is made obsolete by something like #9566?

  23. practicalswift commented at 8:43 PM on December 3, 2018: contributor

    @MarcoFalke Yes, guess so.

    Perhaps I should close this PR? The interest in making GetTime{Millis,Micros}() noexcept seems to be limited: only @sipa, @ken2812221 and I have expressed interest in getting this in :-)

  24. practicalswift closed this on Dec 19, 2018

  25. practicalswift cross-referenced this on Sep 25, 2019 from issue 9% less memory: make SaltedOutpointHasher noexcept by martinus
  26. practicalswift cross-referenced this on Nov 19, 2019 from issue util: Make logging noexcept by laanwj
  27. practicalswift deleted the branch on Apr 10, 2021
  28. bitcoin locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC