1) Updated quadtree.retrieve() to allow passing results array to retrieve to avoid creating arrays during retrieval.
( This option to allow reusing a results array is used in Unity physics hit test functions so I don't consider it too unreasonable.)
2) getIndex() not called if objects.length >0 since objects are only stored in leaf nodes.
All npm tests passed.
I don't consider this premature optimization because geometric queries are often performance critical by nature. (Graphics and game libraries, thousands of hit tests per frame, etc. ) I didn't test these changes were actually faster but it should be.
Don't know about the whitespace. VSCode likes to autoformat.
1) Updated quadtree.retrieve() to allow passing
results
array to retrieve to avoid creating arrays during retrieval. ( This option to allow reusing a results array is used in Unity physics hit test functions so I don't consider it too unreasonable.)2) getIndex() not called if objects.length >0 since objects are only stored in leaf nodes.
All npm tests passed.
I don't consider this premature optimization because geometric queries are often performance critical by nature. (Graphics and game libraries, thousands of hit tests per frame, etc. ) I didn't test these changes were actually faster but it should be.
Don't know about the whitespace. VSCode likes to autoformat.