Skip to content

Commit c0901c3

Browse files
committed
Allocations optimization
See pull request Allocations optimization for converters quickfix-j#34
1 parent b5d77b7 commit c0901c3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

quickfixj-core/src/main/java/quickfix/field/converter/AbstractDateTimeConverter.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.text.DateFormat;
2323
import java.text.DateFormatSymbols;
24+
import java.text.FieldPosition;
2425
import java.text.SimpleDateFormat;
2526
import java.util.Locale;
2627
import java.util.TimeZone;
@@ -56,18 +57,31 @@ protected static void throwFieldConvertError(String value, String type)
5657
}
5758

5859
protected static long parseLong(String s) {
60+
return parseLong(s, 0, s.length());
61+
}
62+
63+
protected static long parseLong(String s, int begin, int end) {
5964
long n = 0;
60-
for (int i = 0; i < s.length(); i++) {
65+
for (int i = begin; i < end; i++) {
6166
n = (n * 10) + (s.charAt(i) - '0');
6267
}
6368
return n;
6469
}
6570

66-
protected DateFormat createDateFormat(String format) {
71+
protected static DateFormat createDateFormat(String format) {
6772
SimpleDateFormat sdf = new SimpleDateFormat(format);
6873
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
6974
sdf.setDateFormatSymbols(new DateFormatSymbols(Locale.US));
7075
return sdf;
7176
}
7277

78+
static final class DontCareFieldPosition extends FieldPosition {
79+
// The singleton of DontCareFieldPosition.
80+
static final FieldPosition INSTANCE = new DontCareFieldPosition();
81+
82+
private DontCareFieldPosition() {
83+
super(0);
84+
}
85+
}
86+
7387
}

0 commit comments

Comments
 (0)