This seems like a massive unnecessary delay! It ought to only reload the file if it has been modified.
true it's not the best way but I wouldn't call it a massive delay... timing the disk accesses on my computer they typically take 0.001-0.003s ranging up to 0.01s in the worst case - I really don't think it's going to affect the success rate but it's a good point. I'll change it in the next version
The fact you somehow got Expons attention and he posted.. You sir, are a winner in my books! Hi Expon!
Another thing, what is the deal with the post-restock pause? Is it still buying during this time? Must be so or I can't imagine it would ever get any buys. I was also going to suggest using a hash table for the list instead of iterating an array, since the complexity is (list size)*(stock size). Then I figured out it takes 1mil+ string comparisons before breaching 1ms on my trash laptop.
Hi Junior what! I have posted at least 10 times in the last month the after restock pause happens only once there are no items on your list left in stock, some other tasks like auto pricing take place during this pause
There would be no point in using a HashTable (called a Dictionary in the .NET Framework). The performance of iterating through an array is actually better than that of a HashTable/Dictionary because it contains a key, value pair. In addition, there would be no need in having a key, value pair. It's just a waste of memory. However, using a HashSet may improve performance of the program in the microseconds because of its fast read (and write) access times. The benefits would minimal. The most noticeable improvements would be made to the wrapper - perhaps including pipelining into the wrapper?
Ah, a HashSet. I snooped around for such a thing, I'm not familiar with .NET though. There is really no reason to iterate through the HashTable! You just check if your key is in the table. You can ignore the value (apparently it can be null), in which case I think it is basically the same as a HashSet. You're right though, it's a massive concession of space in order to increase speed, in this case by undetectable amounts, so clearly it doesn't make sense. Maybe if your item list includes a significant portion of all possible items Edit: Thanks for the clarification about the restock pause.