You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by cc...@apache.org on 2015/10/07 21:26:53 UTC
[33/37] incubator-groovy git commit: Avoid usage of
System.currentTimeMillis which is both slow and not stable across various
OSes
Avoid usage of System.currentTimeMillis which is both slow and not stable across various OSes
Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/f08195f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/f08195f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/f08195f1
Branch: refs/heads/master
Commit: f08195f1ca66488e257c6bec040e6ca83db70df7
Parents: 053af2e
Author: Cedric Champeau <ce...@gmail.com>
Authored: Tue Dec 30 11:06:12 2014 +0100
Committer: Sergei Egorov <bs...@gmail.com>
Committed: Mon Sep 28 14:33:13 2015 +0300
----------------------------------------------------------------------
.../groovy/org/codehaus/groovy/macro/runtime/MacroBuilder.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/f08195f1/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/runtime/MacroBuilder.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/runtime/MacroBuilder.java b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/runtime/MacroBuilder.java
index 1edbcba..2895ebf 100644
--- a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/runtime/MacroBuilder.java
+++ b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/runtime/MacroBuilder.java
@@ -32,6 +32,7 @@ import org.codehaus.groovy.macro.transform.MacroTransformation;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
/**
*
@@ -52,10 +53,12 @@ public enum MacroBuilder {
return macro(compilePhase, false, source, context, resultClass);
}
+ private final static AtomicInteger COUNTER = new AtomicInteger();
+
@SuppressWarnings("unchecked")
public <T> T macro(CompilePhase compilePhase, boolean asIs, String source, final Map<MacroSubstitutionKey, Closure<Expression>> context, Class<T> resultClass) {
boolean isClosure = source.startsWith("{");
- final String label = isClosure ?"__synthesized__label__" + System.currentTimeMillis() + "__:":"";
+ final String label = isClosure ?"__synthesized__label__" + COUNTER.incrementAndGet() + "__:":"";
final String labelledSource = label + source;
final int linesOffset = 1;
final int columnsOffset = label.length() + (isClosure?1:0); // +1 because of {