From 13f4af49109058986e744dc2173afad9ff0868f0 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Fri, 19 Dec 2014 10:14:41 +0000 Subject: bugfix and tiny optimization for callbacks from Haskell --- src/runtime/haskell-bind/PGF2.hsc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/runtime/haskell-bind/PGF2.hsc') diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc index aa752d4b0..44f9d2b1c 100644 --- a/src/runtime/haskell-bind/PGF2.hsc +++ b/src/runtime/haskell-bind/PGF2.hsc @@ -318,11 +318,8 @@ mkCallbacksMap concr callbacks pool = do where match_callback match _ clin_idx csentence poffset out_pool = do sentence <- peekCString csentence - coffset <- peek poffset - offset <- alloca $ \pcsentence -> do - poke pcsentence csentence - gu2hs_string_offset pcsentence (plusPtr csentence (fromIntegral coffset)) 0 - case match (fromIntegral clin_idx) sentence offset of + coffset <- peek poffset + case match (fromIntegral clin_idx) sentence (fromIntegral coffset) of Nothing -> return nullPtr Just (e,prob,offset') -> do poke poffset (fromIntegral offset') @@ -345,13 +342,6 @@ mkCallbacksMap concr callbacks pool = do predict_callback _ _ _ _ = return nullPtr - gu2hs_string_offset pcstart cend offset = do - cstart <- peek pcstart - if cstart < cend - then do gu_utf8_decode pcstart - gu2hs_string_offset pcstart cend (offset+1) - else return offset - linearize :: Concr -> Expr -> String linearize lang e = unsafePerformIO $ withGuPool $ \pl -> -- cgit v1.2.3