summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-13 15:20:06 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-13 15:20:06 +0000
commit9155d5610ba464d0717d536371ff002b4406b0ab (patch)
treea56741d9c711553ccc6055f96cd616013f2fb917 /base
parent8b5ac3aa3be206660efb5ac4f95ab48c4dab117e (diff)
downloadchromium_src-9155d5610ba464d0717d536371ff002b4406b0ab.zip
chromium_src-9155d5610ba464d0717d536371ff002b4406b0ab.tar.gz
chromium_src-9155d5610ba464d0717d536371ff002b4406b0ab.tar.bz2
Inline the TimeDelta::From* construction functions.
With GCC, we don't have much hope of inlining unless the defintion is in the header. This should also hopefully allow the compiler to do things like constant folding on the multiplications, etc. Review URL: http://codereview.chromium.org/17802 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/time.cc30
-rw-r--r--base/time.h32
2 files changed, 32 insertions, 30 deletions
diff --git a/base/time.cc b/base/time.cc
index 83b5c09..12519aa 100644
--- a/base/time.cc
+++ b/base/time.cc
@@ -12,36 +12,6 @@ namespace base {
// TimeDelta ------------------------------------------------------------------
-// static
-TimeDelta TimeDelta::FromDays(int64 days) {
- return TimeDelta(days * Time::kMicrosecondsPerDay);
-}
-
-// static
-TimeDelta TimeDelta::FromHours(int64 hours) {
- return TimeDelta(hours * Time::kMicrosecondsPerHour);
-}
-
-// static
-TimeDelta TimeDelta::FromMinutes(int64 minutes) {
- return TimeDelta(minutes * Time::kMicrosecondsPerMinute);
-}
-
-// static
-TimeDelta TimeDelta::FromSeconds(int64 secs) {
- return TimeDelta(secs * Time::kMicrosecondsPerSecond);
-}
-
-// static
-TimeDelta TimeDelta::FromMilliseconds(int64 ms) {
- return TimeDelta(ms * Time::kMicrosecondsPerMillisecond);
-}
-
-// static
-TimeDelta TimeDelta::FromMicroseconds(int64 us) {
- return TimeDelta(us);
-}
-
int TimeDelta::InDays() const {
return static_cast<int>(delta_ / Time::kMicrosecondsPerDay);
}
diff --git a/base/time.h b/base/time.h
index cb0eeb8..d50b45f 100644
--- a/base/time.h
+++ b/base/time.h
@@ -342,6 +342,38 @@ inline Time TimeDelta::operator+(Time t) const {
return Time(t.us_ + delta_);
}
+// Inline the TimeDelta factory methods, for fast TimeDelta construction.
+
+// static
+inline TimeDelta TimeDelta::FromDays(int64 days) {
+ return TimeDelta(days * Time::kMicrosecondsPerDay);
+}
+
+// static
+inline TimeDelta TimeDelta::FromHours(int64 hours) {
+ return TimeDelta(hours * Time::kMicrosecondsPerHour);
+}
+
+// static
+inline TimeDelta TimeDelta::FromMinutes(int64 minutes) {
+ return TimeDelta(minutes * Time::kMicrosecondsPerMinute);
+}
+
+// static
+inline TimeDelta TimeDelta::FromSeconds(int64 secs) {
+ return TimeDelta(secs * Time::kMicrosecondsPerSecond);
+}
+
+// static
+inline TimeDelta TimeDelta::FromMilliseconds(int64 ms) {
+ return TimeDelta(ms * Time::kMicrosecondsPerMillisecond);
+}
+
+// static
+inline TimeDelta TimeDelta::FromMicroseconds(int64 us) {
+ return TimeDelta(us);
+}
+
// TimeTicks ------------------------------------------------------------------
class TimeTicks {