1
1
package com .fasterxml .jackson .dataformat .csv .impl ;
2
2
3
+ import com .fasterxml .jackson .core .JsonGenerator ;
3
4
import com .fasterxml .jackson .core .io .CharTypes ;
4
5
import com .fasterxml .jackson .core .io .IOContext ;
5
6
import com .fasterxml .jackson .dataformat .csv .CsvGenerator ;
@@ -116,6 +117,11 @@ public class CsvEncoder
116
117
*/
117
118
protected boolean _cfgEscapeControlCharWithEscapeChar ;
118
119
120
+ /**
121
+ * @since 2.14
122
+ */
123
+ protected boolean _cfgUseFastDoubleWriter ;
124
+
119
125
protected final char _cfgQuoteCharEscapeChar ;
120
126
121
127
/**
@@ -193,10 +199,18 @@ public class CsvEncoder
193
199
/**********************************************************
194
200
*/
195
201
202
+
203
+ @ Deprecated //since 2.14
196
204
public CsvEncoder (IOContext ctxt , int csvFeatures , Writer out , CsvSchema schema )
205
+ {
206
+ this (ctxt , csvFeatures , out , schema , false );
207
+ }
208
+
209
+ public CsvEncoder (IOContext ctxt , int csvFeatures , Writer out , CsvSchema schema , boolean useFastDoubleWriter )
197
210
{
198
211
_ioContext = ctxt ;
199
212
_csvFeatures = csvFeatures ;
213
+ _cfgUseFastDoubleWriter = useFastDoubleWriter ;
200
214
_cfgOptimalQuoting = CsvGenerator .Feature .STRICT_CHECK_FOR_QUOTING .enabledIn (csvFeatures );
201
215
_cfgIncludeMissingTail = !CsvGenerator .Feature .OMIT_MISSING_TAIL_COLUMNS .enabledIn (_csvFeatures );
202
216
_cfgAlwaysQuoteStrings = CsvGenerator .Feature .ALWAYS_QUOTE_STRINGS .enabledIn (csvFeatures );
@@ -235,6 +249,7 @@ public CsvEncoder(CsvEncoder base, CsvSchema newSchema)
235
249
{
236
250
_ioContext = base ._ioContext ;
237
251
_csvFeatures = base ._csvFeatures ;
252
+ _cfgUseFastDoubleWriter = base ._cfgUseFastDoubleWriter ;
238
253
_cfgOptimalQuoting = base ._cfgOptimalQuoting ;
239
254
_cfgIncludeMissingTail = base ._cfgIncludeMissingTail ;
240
255
_cfgAlwaysQuoteStrings = base ._cfgAlwaysQuoteStrings ;
@@ -586,7 +601,7 @@ protected void appendValue(long value) throws IOException
586
601
587
602
protected void appendValue (float value ) throws IOException
588
603
{
589
- String str = NumberOutput .toString (value );
604
+ String str = NumberOutput .toString (value , _cfgUseFastDoubleWriter );
590
605
final int len = str .length ();
591
606
if ((_outputTail + len ) >= _outputEnd ) { // >= to include possible comma too
592
607
_flushBuffer ();
@@ -599,7 +614,7 @@ protected void appendValue(float value) throws IOException
599
614
600
615
protected void appendValue (double value ) throws IOException
601
616
{
602
- String str = NumberOutput .toString (value );
617
+ String str = NumberOutput .toString (value , _cfgUseFastDoubleWriter );
603
618
final int len = str .length ();
604
619
if ((_outputTail + len ) >= _outputEnd ) { // >= to include possible comma too
605
620
_flushBuffer ();
0 commit comments