• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Martomate / TriPaint / 8896742719

30 Apr 2024 02:39PM UTC coverage: 27.877% (+0.3%) from 27.558%
8896742719

push

github

Martomate
Fixed major performance issue

4 of 6 new or added lines in 1 file covered. (66.67%)

40 existing lines in 5 files now uncovered.

373 of 1338 relevant lines covered (27.88%)

0.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/src/main/scala/tripaint/model/image/ImagePool.scala
1
package tripaint.model.image
2

3
import tripaint.model.coords.StorageCoords
4
import tripaint.model.image.format.StorageFormat
5
import tripaint.util.{InjectiveHashMap, InjectiveMap}
6

7
import java.io.File
8
import scala.collection.mutable
9

10
object ImagePool {
11
  case class SaveInfo(format: StorageFormat)
1✔
12
  case class SaveLocation(file: File, offset: StorageCoords = StorageCoords(0, 0))
13
}
14

15
/** This class should keep track of Map[SaveLocation, ImageStorage] So if SaveAs then this class
16
  * should be called so that collisions can be detected and dealt with, like e.g. when you save A
17
  * into the same place as B the user should be asked which image to keep, and after that they will
18
  * share the same ImageStorage.
19
  */
20
class ImagePool {
21
  import ImagePool.{SaveInfo, SaveLocation}
22

1✔
23
  private val mapping: InjectiveMap[SaveLocation, ImageStorage] = new InjectiveHashMap
1✔
24
  private val saveInfo: mutable.Map[ImageStorage, SaveInfo] = mutable.Map.empty
25

1✔
26
  final def locationOf(image: ImageStorage): Option[SaveLocation] = mapping.getLeft(image)
27

×
28
  def getSaveLocationAndInfo(image: ImageStorage): (Option[SaveLocation], Option[SaveInfo]) =
×
29
    (mapping.getLeft(image), saveInfo.get(image))
30

1✔
31
  def imageAt(location: SaveLocation): Option[ImageStorage] = mapping.getRight(location)
32

1✔
UNCOV
33
  def set(image: ImageStorage, location: SaveLocation, info: SaveInfo): Unit =
×
34
    mapping.getRight(location).foreach(this.remove)
1✔
35
    mapping.set(location, image)
1✔
36
    saveInfo(image) = info
37

1✔
38
  def remove(image: ImageStorage): Unit =
1✔
39
    mapping.removeRight(image)
1✔
40
    saveInfo.remove(image)
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc