
Don Stewart
mkAnn :: ByteString -> Annotation mkAnn = pick . B.words where pick (_db:up:rest) = pick' up $ getGo rest pick' up' (go:_:ev:_) = Ann (B.copy up') (read $ B.unpack go) (read $ B.unpack ev) getGo = dropWhile (not . B.isPrefixOf (pack "GO:"))
read $ B.unpack go
Looks suspicious. You're unpacking to lists.
ByteString performance rule 1: don't unpack to lists.
I tend to use this idiom a bit when I want to loop over the characters. The strings being unpacked is an Int and a short (two or three letter) identifier. Doing a 'go' loop would probably be faster, but a lot more work, and I was hoping the String would be deforested or fused or otherwise optimized to the bone. I wonder if the culprit is the last 'read', it reads one from a set of keywords/identifiers, and since they're upper case, I just made a data type with a matching set of nullary constructors, and derived "Read" for it. I.e:
data EvidenceCode = IAC | IUG | IFR | NAC | NR | ... deriving Show
Could it be that this derived read instance is somehow very inefficient? -k -- If I haven't seen further, it is by standing in the footprints of giants