Skip to content

Commit

Permalink
Slightly faster formulation - avoid keyword lookups in hot paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuernber committed Feb 24, 2024
1 parent 69f71f6 commit bd47d86
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/tech/v3/dataset/io/column_parsers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@

(defn- missing-value?
"Is this a missing value coming from a CSV file"
[value options]
[value disable-na-as-missing?]
;;fastpath for numbers
(cond
(or (instance? Double value) (instance? Float value))
Expand All @@ -181,7 +181,7 @@
(or (nil? value)
(.equals "" value)
(identical? value :tech.v3.dataset/missing)
(and (not (:disable-na-as-missing? options))
(and (not disable-na-as-missing?)
(string? value) (.equalsIgnoreCase ^String value "na")))))


Expand Down Expand Up @@ -211,7 +211,7 @@
;;be in the space of the container or it could require the parse-fn
;;to make it.
(let [parsed-value (cond
(missing-value? value {})
(missing-value? value false)
:tech.v3.dataset/missing
(and (identical? (dtype/datatype value) container-dtype)
(not (instance? String value)))
Expand Down Expand Up @@ -381,7 +381,8 @@
^List promotion-list
column-name
^:unsynchronized-mutable ^long last-idx
options]
options
disable-na-as-missing?]
dtype-proto/PECount
(ecount [_this] (inc last-idx))
Indexed
Expand All @@ -396,7 +397,7 @@
(addValue [_p idx value]
(let [parsed-value
(cond
(missing-value? value options)
(missing-value? value disable-na-as-missing?)
:tech.v3.dataset/missing


Expand Down Expand Up @@ -468,7 +469,8 @@
parser-datatype-sequence)
column-name
-1
options)))
options
(get options :disable-na-as-missing?))))
(^PParser [column-name options]
(promotional-string-parser column-name default-parser-datatype-sequence options)))

Expand Down

0 comments on commit bd47d86

Please sign in to comment.