git.iko.soy/typeable/timezone-olson
on master help sign in
Cache assoc. list when indexing TZ name strings for rendering.
commit5d501f7cb13a2c5809c8171831baafff1528d4da authorYitzchak Gale <gale@sefer.org> dateMon 17 May 2010, 12:04 (16 years ago) parent183d9a8
1 file changed+3−2
Data/Time/LocalTime/TimeZone/Olson/Render.hs+3−2
Data/Time/LocalTime/TimeZone/Olson/Render.hs+3−2
@@ -148,10 +148,11 @@ putOlsonPart version putTime (OlsonData transs ttinfos leaps _) = do
148148 ttinfosWithTtype = takeWhile ((<= UTC) . tt_ttype) ttinfosIndexed
149149 abbrStrings = uniq . sort $ map tt_abbr ttinfos
150150 abbrChars = concatMap (++ "\NUL") abbrStrings
151+ abbrAssocs = zip abbrStrings . scanl (+) 0 $
152+ map ((+ 1) . length) abbrStrings
151153 ttinfosIndexed = [TtInfo gmtoff isdst ttype i |
152154 TtInfo gmtoff isdst ttype abbr <- ttinfos,
153− i <- maybeToList . lookup abbr . zip abbrStrings .
154− scanl (+) 0 $ map ((+ 1) . length) abbrStrings]
155+ i <- maybeToList $ lookup abbr abbrAssocs]
155156
156157putPosixTZ :: Maybe String -> Put
157158putPosixTZ posix = do