You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2023/05/10 03:21:53 UTC
[groovy-website] branch asf-site updated: tweak wording
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-website.git
The following commit(s) were added to refs/heads/asf-site by this push:
new c80e57a tweak wording
c80e57a is described below
commit c80e57a435459a3d6ca95d7e832ce5038a1d5940
Author: Paul King <pa...@asert.com.au>
AuthorDate: Wed May 10 13:21:41 2023 +1000
tweak wording
---
site/src/site/blog/groovy-record-performance.adoc | 14 ++++++++------
site/src/site/blog/img/hashcodeTimes.png | Bin 32210 -> 35430 bytes
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/site/src/site/blog/groovy-record-performance.adoc b/site/src/site/blog/groovy-record-performance.adoc
index 0562ca6..369b0b7 100644
--- a/site/src/site/blog/groovy-record-performance.adoc
+++ b/site/src/site/blog/groovy-record-performance.adoc
@@ -379,7 +379,7 @@ reduced speed of those implementations.
Groovy records default to Java behavior here but allow you to use the getters
for `hashCode` (and `equals` and `toString`) if you so desire. It will be slower
-be preserves traditional JavaBean-like getter behavior.
+but now preserves traditional JavaBean-like getter behavior.
Here is what the code would look like:
@@ -391,8 +391,10 @@ record GroovyRecordUpperGetter(String x0, String x1, String x2) {
}
----
-The explicit annotation turns on Groovy's emulated record bytecode
-which is the same algorithm but defaults to using the getters.
+The explicit `@EqualsAndHashCode` annotation tells the compiler to provide
+Groovy's default generated `hashCode` bytecode which does use getters rather
+than special record bytecode. It ends up being the same hashing algorithm but
+use the getters to access the components.
And now our tests pass (with `assertEquals` instead of `assertNotEquals`):
@@ -409,8 +411,8 @@ assertEquals(GROOVY_UPPER_GETTER_1.hashCode(), GROOVY_UPPER_GETTER_2.hashCode())
==== Summary
Groovy records have good `hashCode` performance. There are times when you might want to
-enable caching. Rarely, you might want to also consider swapping the hashing algorithm
-or enabling getters, but if you need to, Groovy makes that easy too.
+enable caching. On rare occasions, you might want to also consider swapping the hashing
+algorithm or enabling getters, but if you need to, Groovy makes that easy too.
== Performance of `equals`
@@ -512,7 +514,7 @@ Never-the-less, for this particular example, it might be better style to leave t
normal field access in place and provide something like a compact canonical
constructor to truncate the points during construction.
-== Summary
+== Conclusion
We have looked at a few aspects of the performance of Groovy records and compared
them to other languages. Groovy's default behavior piggybacks directly on Java's
diff --git a/site/src/site/blog/img/hashcodeTimes.png b/site/src/site/blog/img/hashcodeTimes.png
index db066e5..e1f49d7 100644
Binary files a/site/src/site/blog/img/hashcodeTimes.png and b/site/src/site/blog/img/hashcodeTimes.png differ