Ensure that -first-item is as fast as car #210

Merged
merged 1 commit into from Feb 8, 2017

Projects

None yet

3 participants

@Wilfred
Contributor
Wilfred commented Feb 7, 2017

Add symbol properties to -first-item so the byte-compiler compiles
calls to the car opcode. This ensures that -first-item has the same
performance as car.

Add symbol properties to -first-item so the byte-compiler compiles
calls to the car opcode. This ensures that -first-item has the same
performance as car.

For example, given the following function:

(defun wh/call-first-item (x)
  (-first-item x))

This would compile to:

byte code for wh/call-first-item:
  args: (arg1)
0	constant  -first-item
1	stack-ref 1
2	call	  1
3	return

Whereas it now compiles to:

byte code for wh/call-first-item:
  args: (arg1)
0       dup
1       car
2       return
@Wilfred Wilfred Ensure that -first-item is as fast as car
Add symbol properties to -first-item so the byte-compiler compiles
calls to the car opcode. This ensures that -first-item has the same
performance as car.

For example, given the following function:

    (defun wh/call-first-item (x)
      (-first-item x))

This would compile to:

    byte code for wh/call-first-item:
      args: (arg1)
    0	constant  -first-item
    1	stack-ref 1
    2	call	  1
    3	return

Whereas it now compiles to:

    byte code for wh/call-first-item:
      args: (arg1)
    0       dup
    1       car
    2       return
75cde71
@magnars magnars merged commit 98e819e into magnars:master Feb 8, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@magnars
Owner
magnars commented Feb 8, 2017

👍

@Fuco1
Collaborator
Fuco1 commented Feb 8, 2017

I hoped defalias would do this :/ Maybe we should go over all of them and add this where appropriate.

@Wilfred Wilfred deleted the Wilfred:car_opcode_with_first_item branch Feb 8, 2017
@Wilfred
Contributor
Wilfred commented Feb 8, 2017

@Fuco1 yep, me too. I had a quick look but I didn't see any other aliases that have specific byte codes associated with them.

@Fuco1
Collaborator
Fuco1 commented Feb 8, 2017

Okey, thanks for double-checking that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment