Skip to content

Commit aeef773

Browse files
committed
Calculate the booleans once; prepares for CSV-78
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1305700 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8a683f0 commit aeef773

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class CSVFormat implements Serializable {
4141
private final String lineSeparator; // for outputs
4242
private final String[] header;
4343

44+
private final boolean isEscaping;
45+
private final boolean isCommentingEnabled;
46+
private final boolean isEncapsulating;
4447

4548
/**
4649
* Constant char to be used for disabling comments, escapes and encapsulation.
@@ -156,6 +159,9 @@ public class CSVFormat implements Serializable {
156159
this.emptyLinesIgnored = emptyLinesIgnored;
157160
this.lineSeparator = lineSeparator;
158161
this.header = header;
162+
this.isEncapsulating = encapsulator != DISABLED;
163+
this.isCommentingEnabled = commentStart != DISABLED;
164+
this.isEscaping = escape != DISABLED;
159165
}
160166

161167
/**
@@ -243,7 +249,7 @@ public CSVFormat withEncapsulator(char encapsulator) {
243249
}
244250

245251
boolean isEncapsulating() {
246-
return this.encapsulator != DISABLED;
252+
return isEncapsulating;
247253
}
248254

249255
/**
@@ -276,7 +282,7 @@ public CSVFormat withCommentStart(char commentStart) {
276282
* @return <tt>true</tt> is comments are supported, <tt>false</tt> otherwise
277283
*/
278284
public boolean isCommentingEnabled() {
279-
return this.commentStart != DISABLED;
285+
return isCommentingEnabled;
280286
}
281287

282288
/**
@@ -304,7 +310,7 @@ public CSVFormat withEscape(char escape) {
304310
}
305311

306312
boolean isEscaping() {
307-
return this.escape != DISABLED;
313+
return isEscaping;
308314
}
309315

310316
/**

0 commit comments

Comments
 (0)