-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Labels
LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performance
Description
In time, for any values of wall and ext, the results of IsZero2 and IsZero are exactly the same, but IsZero2 is simpler and more efficient. Can IsZero2 replace IsZero?
func (t Time) IsZero2() bool {
return t.wall == 0 && t.ext == 0
}
Line 262 in 29d43df
| func (t Time) IsZero() bool { |
func (t Time) IsZero() bool {
return t.sec() == 0 && t.nsec() == 0
}
// nsec returns the time's nanoseconds.
func (t *Time) nsec() int32 {
return int32(t.wall & nsecMask)
}
// sec returns the time's seconds since Jan 1 year 1.
func (t *Time) sec() int64 {
if t.wall&hasMonotonic != 0 {
return wallToInternal + int64(t.wall<<1>>(nsecShift+1))
}
return t.ext
}
Metadata
Metadata
Assignees
Labels
LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performance