Skip to content

Commit

Permalink
Remove all uses of splatting to avoid related performance hits
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Aug 8, 2014
1 parent 07e2c42 commit 1a2a86b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/dates/query.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const MONTHDAYS = [0,31,59,90,120,151,181,212,243,273,304,334]
dayofyear(y,m,d) = MONTHDAYS[m] + d + (m > 2 && isleapyear(y))

### Days of the Week
dayofweek(dt::TimeType) = dayofweek(days(dt))

const Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday = 1,2,3,4,5,6,7
const Mon,Tue,Wed,Thu,Fri,Sat,Sun = 1,2,3,4,5,6,7
const english_daysofweek = [1=>"Monday",2=>"Tuesday",3=>"Wednesday",
Expand All @@ -24,8 +26,6 @@ const VALUETODAYOFWEEKABBR = (UTF8String=>Dict{Int,UTF8String})["english"=>engli
dayname(dt::TimeType;locale::String="english") = VALUETODAYOFWEEK[locale][dayofweek(dt)]
dayabbr(dt::TimeType;locale::String="english") = VALUETODAYOFWEEKABBR[locale][dayofweek(dt)]

dayofweek(dt::TimeType) = dayofweek(days(dt))

# Convenience methods for each day
ismonday(dt::TimeType) = dayofweek(dt) == Mon
istuesday(dt::TimeType) = dayofweek(dt) == Tue
Expand Down Expand Up @@ -73,7 +73,7 @@ const VALUETOMONTHABBR = (UTF8String=>Dict{Int,UTF8String})["english"=>englishab
monthname(dt::TimeType;locale::String="english") = VALUETOMONTH[locale][month(dt)]
monthabbr(dt::TimeType;locale::String="english") = VALUETOMONTHABBR[locale][month(dt)]

daysinmonth(dt::TimeType) = daysinmonth(yearmonth(dt)...)
daysinmonth(dt::TimeType) = ((y,m) = yearmonth(dt); return daysinmonth(y,m))

@vectorize_1arg TimeType monthname
@vectorize_1arg TimeType monthabbr
Expand All @@ -82,7 +82,7 @@ daysinmonth(dt::TimeType) = daysinmonth(yearmonth(dt)...)
### Years
isleapyear(dt::TimeType) = isleapyear(year(dt))

dayofyear(dt::TimeType) = dayofyear(yearmonthday(dt)...)
dayofyear(dt::TimeType) = ((y,m,d) = yearmonthday(dt); return dayofyear(y,m,d))

daysinyear(dt::TimeType) = 365 + isleapyear(dt)

Expand Down

0 comments on commit 1a2a86b

Please sign in to comment.