forked from jruby/jruby
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid creating intermediate symbols for attr assigns
Attribute assignment with a user-provided symbol creates a new ByteList with '=' appended, and then proceeds to look up any existing symbol with that new name. If the name exists, the intermediate ByteList is a wasted allocation. This patch provides another way to look up a symbol with a single- character suffix without creating a new ByteList to hold those bytes. In a quick and dirty profile, use of the previous commit's ByteList.copyAndAppend almost entirely disappears, and overall byte[] and ByteList allocations are largely limited to creating the original identifier name. This technique could be extended to support looking up a symbol based on a range of bytes, avoiding any copying when the bytes are already represented by an existing symbol.
- Loading branch information
Showing
2 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters