allow nested Template within thread

This commit is contained in:
Jonathan Shook 2020-09-03 12:11:33 -05:00
parent 428ffe718f
commit 0ce2f6356f

View File

@ -41,7 +41,7 @@ public class Template implements LongFunction<String> {
private final static Logger logger = LogManager.getLogger(Template.class); private final static Logger logger = LogManager.getLogger(Template.class);
private static final String EXPR_BEGIN = "[["; private static final String EXPR_BEGIN = "[[";
private static final String EXPR_END = "]]"; private static final String EXPR_END = "]]";
private final static ThreadLocal<StringBuilder> sb = ThreadLocal.withInitial(StringBuilder::new); // private final static ThreadLocal<StringBuilder> sb = ThreadLocal.withInitial(StringBuilder::new);
private final String rawTemplate; private final String rawTemplate;
private LongUnaryOperator iterOp; private LongUnaryOperator iterOp;
private String[] literals; private String[] literals;
@ -138,7 +138,7 @@ public class Template implements LongFunction<String> {
@Override @Override
public String apply(long value) { public String apply(long value) {
StringBuilder buffer = sb.get(); StringBuilder buffer = new StringBuilder();
buffer.setLength(0); buffer.setLength(0);
buffer.append(literals[0]); buffer.append(literals[0]);
if (literals.length > 1) { if (literals.length > 1) {