]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/ResponseWriter.hs
Slight speed improvement
[Lucu.git] / Network / HTTP / Lucu / ResponseWriter.hs
index a3a6af106071d6d8a5f7b357fab3ee4823e057ef..be9f37088143ebc3e92eb73771b9dd3c1733df92 100644 (file)
@@ -32,7 +32,8 @@ responseWriter cnf h tQueue readerTID
     where
       awaitSomethingToWrite :: IO ()
       awaitSomethingToWrite 
-          = do action
+          = {-# SCC "awaitSomethingToWrite" #-}
+            do action
                    <- atomically $!
                       do -- キューが空でなくなるまで待つ
                          queue <- readTVar tQueue
@@ -56,7 +57,8 @@ responseWriter cnf h tQueue readerTID
 
       writeContinueIfNecessary :: Interaction -> STM (IO ())
       writeContinueIfNecessary itr
-          = itr `seq`
+          = {-# SCC "writeContinueIfNecessary" #-}
+            itr `seq`
             do expectedContinue <- readItr itr itrExpectedContinue id
                if expectedContinue then
                    do wroteContinue <- readItr itr itrWroteContinue id
@@ -78,11 +80,12 @@ responseWriter cnf h tQueue readerTID
           -- れば、ヘッダを出力する。ヘッダ出力後であり、bodyToSend が
           -- 空でなければ、それを出力する。空である時は、もし状態が
           -- Done であれば後処理をする。
-          = itr `seq`
+          = {-# SCC "writeHeaderOrBodyIfNecessary" #-}
+            itr `seq`
             do wroteHeader <- readItr itr itrWroteHeader id
                
                if not wroteHeader then
-                   return $ writeHeader itr
+                   return $! writeHeader itr
                  else
                    do bodyToSend <- readItr itr itrBodyToSend id
 
@@ -98,7 +101,8 @@ responseWriter cnf h tQueue readerTID
 
       writeContinue :: Interaction -> IO ()
       writeContinue itr
-          = itr `seq`
+          = {-# SCC "writeContinue" #-}
+            itr `seq`
             do let cont = Response {
                             resVersion = HttpVersion 1 1
                           , resStatus  = Continue
@@ -112,7 +116,8 @@ responseWriter cnf h tQueue readerTID
 
       writeHeader :: Interaction -> IO ()
       writeHeader itr
-          = itr `seq`
+          = {-# SCC "writeHeader" #-}
+            itr `seq`
             do res <- atomically $! do writeItr itr itrWroteHeader True
                                        readItr itr itrResponse id
                hPutResponse h res
@@ -121,7 +126,8 @@ responseWriter cnf h tQueue readerTID
       
       writeBodyChunk :: Interaction -> IO ()
       writeBodyChunk itr
-          = itr `seq`
+          = {-# SCC "writeBodyChunk" #-}
+            itr `seq`
             do willDiscardBody <- atomically $! readItr itr itrWillDiscardBody id
                willChunkBody   <- atomically $! readItr itr itrWillChunkBody   id
                chunk           <- atomically $! do chunk <- readItr itr itrBodyToSend id
@@ -140,7 +146,8 @@ responseWriter cnf h tQueue readerTID
 
       finishBodyChunk :: Interaction -> IO ()
       finishBodyChunk itr
-          = itr `seq`
+          = {-# SCC "finishBodyChunk" #-}
+            itr `seq`
             do willDiscardBody <- atomically $! readItr itr itrWillDiscardBody id
                willChunkBody   <- atomically $! readItr itr itrWillChunkBody   id
                when (not willDiscardBody && willChunkBody)
@@ -148,7 +155,8 @@ responseWriter cnf h tQueue readerTID
 
       finalize :: Interaction -> IO ()
       finalize itr
-          = itr `seq`
+          = {-# SCC "finalize" #-}
+            itr `seq`
             do finishBodyChunk itr
                willClose <- atomically $!
                             do queue <- readTVar tQueue