-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use defaultValue.EMPTY_OBJECT to avoid unnecessary object creation #7588
Comments
Hi @OmarShehata, I can happily solve this issue for you :) Kind regards, Abu |
@abuDarda97 that would be awesome! Check out the build guide, let me know if you have any questions. |
Hi @OmarShehata in the RenderState.js file under the Renderer folder should I replace all the empty objects with
Also, which testing scripts should I run? |
@abuDarda97 that sounds right. For the tests, see the testing guide here https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Documentation/Contributors/TestingGuide/README.md#running-the-tests |
Hey @OmarShehata I carried out all of the changes, ran all of the tests got 0 failures. However, I have 4 specs on pending. Is it okay to make a PR? |
@abuDarda97 yes, that's normal! The "pending" specs are ones that are actually just intentionally disabled. I wonder if it'd be worth adding a note on that in the testing guide since that was something I was confused about as well when I first ran the tests. But yes, go ahead and open the PR! |
This was done in #7793. |
In most CesiumJS constructors, you'll see this pattern of creating an
options
object if one wasn't specified:https://github.com/AnalyticalGraphicsInc/cesium/blob/f97d63ea010af07d21855e273ac3e0e98397107b/Source/Core/BingMapsGeocoderService.js#L29-L30
We avoid doing
options = defaultValue(options, {});
because this will create a new object and throw it away if anoptions
object was passed. This can be a performance/memory issue especially if this constructor is called a lot.There are a bunch of places where this is not done. A regex search
defaultValue\([\w]+, {}
shows the following files.This would just be a matter of replacing all those with
defaultValue(options, defaultValue.EMPTY_OBJECT)
. @mramato can you label with "Good first issue" ?The text was updated successfully, but these errors were encountered: