Skip to content

Commit cf78aac

Browse files
committed
trying to fix inline image performance
1 parent d59dfb5 commit cf78aac

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

cabal.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ package unix
66
package directory
77
flags: +os-string
88

9+
package miso
10+
flags: +logview
11+
12+
packages:
13+
pub/miso/*.cabal
14+
915
source-repository-package
1016
type: git
1117
location: https://github.com/dorchard/type-level-sets.git

ghcjs/miso-functora/src/Functora/Miso/Widgets/Field.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts
160160
if null src
161161
then mempty
162162
else
163-
[ img_ (src_ src : optsExtraAttributes opts),
163+
[ img_
164+
( loading_ "lazy"
165+
: src_ src
166+
: optsExtraAttributes opts
167+
),
164168
br_ mempty
165169
]
166170
)
@@ -660,7 +664,7 @@ genericFieldViewer opts0 args widget =
660664
opts0
661665
( if typ == FieldTypeImage
662666
then
663-
[ img_ [src_ input]
667+
[ img_ [loading_ "lazy", src_ input]
664668
]
665669
else
666670
[ widget

ghcjs/miso-functora/src/Functora/Miso/Widgets/Icon.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ data Fa
6767
| FaTrash
6868
| FaFloppyDisk
6969
| FaPenToSquare
70-
| FaPaste
70+
| FaClipboard
7171
| FaEye
7272
| FaEyeSlash
7373
| FaAnglesUp
@@ -102,7 +102,7 @@ instance From Icon Fa where
102102
IconDelete -> FaTrash
103103
IconSave -> FaFloppyDisk
104104
IconEdit -> FaPenToSquare
105-
IconPaste -> FaPaste
105+
IconPaste -> FaClipboard
106106
IconVisible -> FaEye
107107
IconHidden -> FaEyeSlash
108108
IconUp -> FaAnglesUp

pub/miso/src/Miso.hs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,27 @@ common App {..} m getView = do
126126
loop !oldModel = liftIO wait >> do
127127
-- Apply actions to model
128128
actions <- liftIO $ atomicModifyIORef' actionsRef $ \actions -> (S.empty, actions)
129+
#ifdef LOGVIEW
130+
tsU0 <- liftIO getCurrentTime
131+
let (Acc newModel effects) = foldl' (foldEffects writeEvent update)
132+
(Acc oldModel (pure ())) actions
133+
effects
134+
tsU1 <- liftIO getCurrentTime
135+
consoleLog . ms . ("update " <>) . show $ diffUTCTime tsU1 tsU0
136+
#else
129137
let (Acc newModel effects) = foldl' (foldEffects writeEvent update)
130138
(Acc oldModel (pure ())) actions
131139
effects
140+
#endif
132141
oldName <- liftIO $ oldModel `seq` makeStableName oldModel
133142
newName <- liftIO $ newModel `seq` makeStableName newModel
134143
when (oldName /= newName && oldModel /= newModel) $ do
135144
swapCallbacks
136145
#ifdef LOGVIEW
137-
ts0 <- liftIO getCurrentTime
146+
tsV0 <- liftIO getCurrentTime
138147
newVTree <- runView (view newModel) writeEvent
139-
ts1 <- liftIO getCurrentTime
140-
consoleLog . ms . show $ diffUTCTime ts1 ts0
148+
tsV1 <- liftIO getCurrentTime
149+
consoleLog . ms . ("view " <>) . show $ diffUTCTime tsV1 tsV0
141150
#else
142151
newVTree <- runView (view newModel) writeEvent
143152
#endif

0 commit comments

Comments
 (0)