Move SSD detection list mutations to typed Kotlin

ober

08702c82dff29b39e0a99cda13ff042e3ca85b3d

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index b023841..130a04c 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -564,7 +564,7 @@
                 ssdSessionFindCellById ssdSessionCellsByIds
                 ssdSessionBBoxForCellIds ssdSessionRecomputeGroup
                 appendUniqueCellIdsToGroup
-                ssdSessionAddDetectedCellsInsideArea
+                ssdSessionAddDetectedCellsInsideArea ssdSessionAddOcrWords
                 ssdSessionBoundedSsdArea ssdAreaSelectionTooSmall
                 ssdSessionStoreSsdArea ssdSessionSsdAreaOutsideCount
                 ssdSessionSetSsdArea ssdSessionPruneGroupsOutsideSsdArea
@@ -655,6 +655,9 @@
             (copyOcrWords (SsdSession-ocrWords source))
             (mutable-list-empty SsdGroup)
             (nullable-none FloatArray)))
+        (def (ssdSessionAddOcrWords (session : SsdSession)
+                                    (words : (List OcrWord))) : Unit
+          (mutable-list-add-all! (SsdSession-ocrWords session) words))
         (def (ssdSessionAreaOrNone (session : (Nullable SsdSession))) : (Nullable FloatArray)
           (if (nullable-null? session)
             (nullable-none FloatArray)
@@ -1075,7 +1078,7 @@
 
     (typed-kotlin-file "com/sfb/ssdreview/SsdDetectorGroups.kt"
       (typed-library (com sfb ssdreview)
-        (export initialGroups initialGroupsLimited)
+        (export initialGroups initialGroupsLimited ssdSessionAddInitialGroups)
         (type Int32)
         (type BooleanArray)
         (def (detectorGroupId (index : Int32)) : String
@@ -1189,7 +1192,12 @@
                   (begin
                     (mutable-list-add! out (list-ref groups i))
                     ignored))
-                out))))))
+                out))))
+        (def (ssdSessionAddInitialGroups (session : SsdSession)
+                                         (limit : Int32)) : Unit
+          (mutable-list-add-all!
+            (SsdSession-groups session)
+            (initialGroupsLimited (SsdSession-cells session) limit)))))
 
     (typed-kotlin-file "com/sfb/ssdreview/SourceKey.kt"
       (typed-library (com sfb ssdreview)
@@ -7186,13 +7194,13 @@
        "                        detectorSource = detectorSourceWithTruth(forceDetect, existingTruthGroupCount, \"forced-android-plus-truth\", \"android-fallback\")"
        "                    }"
        "                    ssdSessionAddDetectedCellsInsideArea(session, detectedCells)"
-       "                    session.groups.addAll(initialGroupsLimited(session.cells, 120))"
+       "                    ssdSessionAddInitialGroups(session, 120)"
        "                    if (shouldApplyExistingTruthObject(existingTruth, existingTruthGroupCount)) {"
        "                        truthStore.applyTruth(session)"
        "                        ssdSessionPruneGroupsOutsideSsdArea(session)"
        "                    }"
        "                    applyInitialGuesses(this, session)"
-       "                    session.ocrWords.addAll(SsdOcr.recognizeWords(bitmap))"
+       "                    ssdSessionAddOcrWords(session, SsdOcr.recognizeWords(bitmap))"
        "                    ocrGuesses = applyOcrGuesses(this, session, SsdOcr.patterns)"
        "                }"
        "                val learnedGuesses = learnedGuessesForDetection(truthStore, session, existingTruthGroupCount)"