You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/06/26 10:03:54 UTC
[groovy] branch master updated: Improve the performance of
`getPropertyName` further
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 041a7e7 Improve the performance of `getPropertyName` further
041a7e7 is described below
commit 041a7e709ae005a3dec06cdeaf7d5f2e36c9f8cc
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Jun 26 18:03:09 2020 +0800
Improve the performance of `getPropertyName` further
---
.../java/org/apache/groovy/ast/tools/MethodNodeUtils.java | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/groovy/ast/tools/MethodNodeUtils.java b/src/main/java/org/apache/groovy/ast/tools/MethodNodeUtils.java
index b553d71..1e2b9d8 100644
--- a/src/main/java/org/apache/groovy/ast/tools/MethodNodeUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/MethodNodeUtils.java
@@ -77,11 +77,15 @@ public class MethodNodeUtils {
* @return the property name without the get/set/is prefix if a property or null
*/
public static String getPropertyName(MethodNode mNode) {
+ boolean startsWithGet = false;
+ boolean startsWithSet = false;
+ boolean startsWithIs = false;
String name = mNode.getName();
- final boolean startsWithSet = name.startsWith("set");
- final boolean startsWithGet = name.startsWith("get");
- final boolean startsWithIs = name.startsWith("is");
- if (startsWithGet || startsWithSet || startsWithIs) {
+
+ if ((startsWithGet = name.startsWith("get"))
+ || (startsWithSet = name.startsWith("set"))
+ || (startsWithIs = name.startsWith("is"))) {
+
final String tmpPname = name.substring(startsWithIs ? 2 : 3);
if (!tmpPname.isEmpty()) {
if (startsWithSet) {
@@ -95,6 +99,7 @@ public class MethodNodeUtils {
}
}
}
+
return null;
}