1
0
Fork 0

Why run the min/max of the array #10

Closed
opened 2023-05-13 15:24:00 +00:00 by ethanready · 2 comments
ethanready commented 2023-05-13 15:24:00 +00:00 (Migrated from github.com)

on lines 207 and 208 you do

var lowestSellOffer = Math.min.apply(Math, buySummary.map(function(o) { return o.pricePerUnit; }));
var highestBuyOrder = Math.max.apply(Math, sellSummary.map(function(o) { return o.pricePerUnit; }));

This seems kinda redundant. I threw the api data into a file just to see what it looked like, and the data is already sorted. grabbing the last item of the sell summary and the first of the buy summary would do the same thing but faster right? I'm asking this question not to be snobby, im just curious if there was a reason/something i missed.

on lines 207 and 208 you do ``` var lowestSellOffer = Math.min.apply(Math, buySummary.map(function(o) { return o.pricePerUnit; })); var highestBuyOrder = Math.max.apply(Math, sellSummary.map(function(o) { return o.pricePerUnit; })); ``` This seems kinda redundant. I threw the api data into a file just to see what it looked like, and the data is already sorted. grabbing the last item of the sell summary and the first of the buy summary would do the same thing but faster right? I'm asking this question not to be snobby, im just curious if there was a reason/something i missed.
ianrenton commented 2023-05-13 16:04:16 +00:00 (Migrated from github.com)

No reason that I remember - I assume I just never realised the data was already sorted!

No reason that I remember - I assume I just never realised the data was already sorted!
ianrenton commented 2023-05-19 15:47:14 +00:00 (Migrated from github.com)

On balance I think I'd rather keep the min/max calculation, just in case. The API documentation doesn't state that the data is ordered, so this provides some protection against future changes, and I don't believe the performance impact is significant.

On balance I think I'd rather keep the min/max calculation, just in case. The API documentation doesn't state that the data is ordered, so this provides some protection against future changes, and I don't believe the performance impact is significant.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ian/Skyblock-Bazaar-Flipping-Calculator#10
No description provided.