Skip to content

Commit

Permalink
making .max calls safer by checking .nonEmpty first (#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fate-JH authored Mar 29, 2024
1 parent 34e2ad5 commit b7dc2b6
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class BlockMap(fullMapWidth: Int, fullMapHeight: Int, desiredSpanSize: Int) {
* @return a conglomerate sector which lists all of the entities in the discovered sector(s)
*/
def sector(indices: Iterable[Int], range: Float): SectorPopulation = {
if (indices.max < blocks.size) {
if (indices.nonEmpty && indices.max < blocks.size) {
BlockMap.quickToSectorGroup(range, BlockMap.sectorsOnlyWithinBlockStructure(indices, blocks) )
} else {
SectorGroup(Nil)
Expand Down Expand Up @@ -527,7 +527,7 @@ object BlockMap {
list: Iterable[Int],
structure: Iterable[Sector]
): Iterable[Sector] = {
if (list.max < structure.size) {
if (list.nonEmpty && list.max < structure.size) {
val structureSeq = structure.toSeq
list.toSet.map { structureSeq }
} else {
Expand Down

0 comments on commit b7dc2b6

Please sign in to comment.