This page is not created by, affiliated with, or supported by Slack Technologies, Inc.


I've just asked this in #clojurescript: i.e., any reason why re-seq does a second search to find out the index of the matched string 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"}


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?


@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.


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


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