Closed GoogleCodeExporter closed 9 years ago
Original comment by kak@google.com
on 23 Jul 2013 at 4:10
I love this sort of bug report. Our general feeling on MediaType.toString()
was "we could make this faster, but let's wait until somebody actually cares."
Well, this counts. :-)
I think we can do a few things that'll help:
1) precompute stings for the constants. seems like an easy win.
2) use single-check lazy init (since the operation is idempotent) for the
toString() value
3) take a look at StringBuilder sizing. We're probably doing extra copies that
make it unnecessarily expensive.
Original comment by gak@google.com
on 23 Jul 2013 at 6:03
Original comment by gak@google.com
on 23 Jul 2013 at 6:03
For what it's worth, I tested a few ways to optimize toString on the first run
(i.e. when its result is not cached). They're nothing in comparison to what
could be gained from gak's suggestions (1) or (2), of course.
I attached the results it spit out. Basically the first run of toString could
be 2-3x faster.
Original comment by michael.hixson@gmail.com
on 25 Jul 2013 at 12:31
Attachments:
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:12
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:17
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:08
Original issue reported on code.google.com by
michael.hixson@gmail.com
on 23 Jul 2013 at 3:40