DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Use singletons for commonly used null first and nulls last comparisons #1647

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Sorry if this issue was already raised or not but is seems to make sense to add 
this.
Main idea is to reduce object creation.
I find myself creating private static instances of ordering that are natural 
and have either nulls last or nulls first applied.
I'd like guava to optimize this for me so  don't have to litter my code with 
this.
Left some todos open since there is room for some more improvements but they 
would require changes to visibility of the NullsFirstOrdering and 
NullsLastOrdering classes. I thought I'd better leave that decision up to you. 
My initial suggestion would be to make the former mentioned classes extensible 
while remaining private to the package. I think it would respect the design 
intent although you may have other reasons to keep the class private and final.
See patch for changes.

Original issue reported on code.google.com by pasfi...@gmail.com on 28 Jan 2014 at 1:08

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by wasserman.louis on 28 Jan 2014 at 2:44

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07