Replace String arguments with Text (#138)

Shave a few allocations and pointer-chasing due to conversion.
This commit is contained in:
Alexander Bondarenko
2022-05-15 22:41:10 +03:00
committed by GitHub
parent 04fe618871
commit 3c1d381c14
5 changed files with 292 additions and 226 deletions

View File

@ -13,6 +13,7 @@ import Data.Bits ((.|.))
import Data.IORef
import Data.List (sortBy)
import Data.Foldable (traverse_)
import Data.Text (Text, pack)
import DearImGui
import DearImGui.OpenGL2
@ -61,7 +62,7 @@ main = do
GLFW.terminate
mainLoop :: Window -> IORef [(Integer, String)] -> IO ()
mainLoop :: Window -> IORef [(Integer, Text)] -> IO ()
mainLoop win tableRef = do
-- Process the event loop
GLFW.pollEvents
@ -102,7 +103,7 @@ mainLoop win tableRef = do
mainLoop win tableRef
mkTable :: IORef [(Integer, String)] -> IO ()
mkTable :: IORef [(Integer, Text)] -> IO ()
mkTable tableRef =
withTableOpen sortable "MyTable" 3 $ do
tableSetupColumn "Hello"
@ -120,7 +121,7 @@ mkTable tableRef =
readIORef tableRef >>=
traverse_ \(ix, title) -> do
tableNextRow
tableNextColumn $ text (show ix)
tableNextColumn $ text (pack $ show ix)
tableNextColumn $ text title
tableNextColumn $ void (button "")
where