on master help sign in
I'm reasonably sure we can use unsafeWrite O_O
commitf224ab18b27e5f08240924e28b3267c2226784f3 authorCorey O'Connor <coreyoconnor@gmail.com> dateThu 14 Jul 2011, 23:40 (15 years ago) parentcc969d9
1 file changed+7−7
src/Graphics/Vty/Span.hs+7−7
src/Graphics/Vty/Span.hs+7−7
@@ -254,24 +254,24 @@ snoc_text_span :: Attr -- the display attributes of the text span
254254 -- defined to the end of the display for the row.
255255 -> ST s Word
256256snoc_text_span a text_str mrow_ops columns_to_skip y remaining_columns = do
257− snoc_op mrow_ops y $ AttributeChange a
257+ {-# SCC "snoc_text_span-pre" #-} snoc_op mrow_ops y $! AttributeChange a
258258 -- At most a text span will consist of remaining_columns characters
259259 -- we keep track of the position of the next character.
260260 let max_len :: Int = fromEnum remaining_columns
261261 mspan_chars <- Vector.new max_len
262262 ( used_display_columns, display_columns_skipped, used_char_count )
263− <- Foldable.foldlM (build_text_span mspan_chars) ( 0, 0, 0 ) text_str
263+ <- {-# SCC "snoc_text_span-foldlM" #-} Foldable.foldlM (build_text_span mspan_chars) ( 0, 0, 0 ) text_str
264264 -- once all characters have been output to mspan_chars we grab the used head
265265 out_text <- Vector.unsafeFreeze $! Vector.take used_char_count mspan_chars
266266 -- convert to UTF8 bytestring.
267267 -- This could be made faster. Hopefully the optimizer does a fair job at fusing the fold
268268 -- contained in fromString with the unfold in toList. No biggy right now then.
269− snoc_op mrow_ops y $! TextSpan used_display_columns (toEnum used_char_count)
269+ {-# SCC "snoc_text_span-post" #-} snoc_op mrow_ops y $! TextSpan used_display_columns (toEnum used_char_count)
270270 $! UTF8.fromString
271271 $! Vector.toList out_text
272272 return $ columns_to_skip - display_columns_skipped
273273 where
274− build_text_span mspan_chars (used_display_columns, display_columns_skipped, used_char_count)
274+ build_text_span mspan_chars (!used_display_columns, !display_columns_skipped, !used_char_count)
275275 (out_char, char_display_width) = {-# SCC "build_text_span" #-}
276276 -- Only valid if the maximum width of a character is 2 display columns.
277277 -- XXX: Optimize into a skip pass then clipped fill pass
@@ -280,20 +280,20 @@ snoc_text_span a text_str mrow_ops columns_to_skip y remaining_columns = do
280280 then return $! ( used_display_columns, display_columns_skipped, used_char_count )
281281 else if ( used_display_columns + char_display_width ) > remaining_columns
282282 then do
283− Vector.write mspan_chars used_char_count '…'
283+ Vector.unsafeWrite mspan_chars used_char_count '…'
284284 return $! ( used_display_columns
285285 , display_columns_skipped
286286 , used_char_count + 1
287287 )
288288 else do
289− Vector.write mspan_chars used_char_count out_char
289+ Vector.unsafeWrite mspan_chars used_char_count out_char
290290 return $! ( used_display_columns + char_display_width
291291 , display_columns_skipped
292292 , used_char_count + 1
293293 )
294294 else if (display_columns_skipped + char_display_width) > columns_to_skip
295295 then do
296− Vector.write mspan_chars used_char_count '…'
296+ Vector.unsafeWrite mspan_chars used_char_count '…'
297297 return $! ( used_display_columns + 1
298298 , columns_to_skip
299299 , used_char_count + 1