amap calls `alength` at every iteration step

Description

During the 1.7 => 1.8 upgrade `areduce` was fixed to not call `alength` on the same thing, at every single iteration step. However, `amap` which suffers from the same issue was not fixed (even though exactly the same fix applies).

Example:

Before (last time): 0.3930 ms
After (last time): 0.3459 ms

Patch: fix_amap.patch

Screened by: Alex Miller

Environment

JVM

Activity

Show:
Alex Miller
March 13, 2016, 10:39 PM

Thanks!

Dimitrios Jim Piliouras
April 24, 2016, 7:33 PM

Not a problem. I actually noticed a very similar thing in the `internal-reduce` implementation for StringSeq [1]. The `.length()` method is called on the same String on every single iteration step, even though it is a constant. Is that easy enough to be sorted without me submitting another trivial patch? Thanks in advance...

https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/protocols.clj#L151

Alex Miller
April 24, 2016, 7:48 PM

Separate ticket would be preferred, thanks.

Dimitrios Jim Piliouras
April 24, 2016, 8:32 PM

Sure thing, I'll create it now.

Completed

Assignee

Unassigned

Reporter

Dimitrios Jim Piliouras

Labels

Approval

Ok

Patch

Code

Fix versions

Affects versions

Priority

Major
Configure