You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/07/13 21:08:00 UTC
[jira] [Work logged] (CSV-283) Remove Whitespace Check Determines
Delimiter Twice
[ https://issues.apache.org/jira/browse/CSV-283?focusedWorklogId=622239&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-622239 ]
ASF GitHub Bot logged work on CSV-283:
--------------------------------------
Author: ASF GitHub Bot
Created on: 13/Jul/21 21:07
Start Date: 13/Jul/21 21:07
Worklog Time Spent: 10m
Work Description: belugabehr opened a new pull request #167:
URL: https://github.com/apache/commons-csv/pull/167
Remove checking twice for delimiter per-loop.
https://issues.apache.org/jira/browse/CSV-283
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Issue Time Tracking
-------------------
Worklog Id: (was: 622239)
Remaining Estimate: 0h
Time Spent: 10m
> Remove Whitespace Check Determines Delimiter Twice
> --------------------------------------------------
>
> Key: CSV-283
> URL: https://issues.apache.org/jira/browse/CSV-283
> Project: Commons CSV
> Issue Type: Improvement
> Reporter: David Mollitor
> Priority: Minor
> Time Spent: 10m
> Remaining Estimate: 0h
>
> {code:java|title=Lexer.java}
> /**
> * Tests if the given char is a whitespace character.
> *
> * @return true if the given char is a whitespace character.
> * @throws IOException If an I/O error occurs.
> */
> boolean isWhitespace(final int ch) throws IOException {
> return !isDelimiter(ch) && Character.isWhitespace((char) ch);
> }
> while (true) {
> c = reader.read();
> if (isDelimiter(c)) {
> token.type = TOKEN;
> return token;
> }
> if (isEndOfFile(c)) {
> ...
> }
> if (readEndOfLine(c)) {
> ...
> }
> if (!isWhitespace(c)) {
> // error invalid char between token and next delimiter
> throw new IOException("(line " + getCurrentLineNumber() +
> ") invalid char between encapsulated token and delimiter");
> }
> }
> {code}
> So the first check is for the delimiter, and it returns quick if it finds it. After that point, it's known that this is NOT a delimiter, so no need to re-check it in {{isWhiteSpace}}. The delimiter check can be somewhat expensive given it may involve a look-ahead IO read.
> Remove the redundancy.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)