Skip to content

Commit

Permalink
Avoid exceeding the call stack size on moderately large arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 26, 2018
1 parent 6d89fbe commit 72f66e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/JBrowse/Store/SeqFeature/_InsertSizeCache.js
Expand Up @@ -31,8 +31,8 @@ return declare(null, {
const len = Object.keys(this.featureCache).length
if(len > this.insertStatsCacheMin) {
const insertSizes = Object.values(this.featureCache).map(v => Math.abs(v))
const max = Math.max(...insertSizes)
const min = Math.min(...insertSizes)
const max = insertSizes.reduce((max, n) => n > max ? n : max)
const min = insertSizes.reduce((min, n) => n < min ? n : min)
const filteredInsertSizes = insertSizes.filter(tlen => tlen < this.insertMaxSize && tlen > this.insertMinSize)
const sum = filteredInsertSizes.reduce((a, b) => a + b, 0)
const sum2 = filteredInsertSizes.map(a => a * a).reduce((a, b) => a + b, 0)
Expand Down

0 comments on commit 72f66e4

Please sign in to comment.