Fork me on GitHub
#cljs-dev
<
2018-07-25
>
euccastro01:07:58

I've just asked this in #clojurescript: https://clojurians.slack.com/archives/C03S1L9DN/p1532481825000054 i.e., any reason why re-seq does a second search to find out the index of the matched string https://github.com/clojure/clojurescript/blob/r1.10.339-24-g0773689e/src/main/cljs/cljs/core.cljs#L9851 instead of using .exec on the regex directly and getting both from there? like

cljs.user> (let [m (.exec #"br\w+" "the quick brown fox yadda yadda")]
             {:index (.-index m) :text (first m)})
{:index 10, :text "brown"}

euccastro02:07:29

I haven't measured what the performance gains would be, if any. I'm just curious if there's a strong reason why it's being done this way. if not, shall I benchmark this change and contribute a patch if the improvement is significant?

mfikes02:07:52

@euccastro Hrm. Looks like it has been that way for 7 years. So it may just be a matter of trying to reverse engineer what it is doing at this point.

euccastro02:07:13

btw what it's doing seems pretty clear. why it's doing it that particular way is what I don't understand yet

euccastro02:07:34

yeah, I was just asking because if there was a well-known reason (e.g. .-index is not available in X browser, or in Node, or ...) then there would be no point in digging into it further

mfikes02:07:55

Right…