Created
December 1, 2011 08:10
-
-
Save bohford/1414879 to your computer and use it in GitHub Desktop.
Stupid JRuby tricks
This file contains hidden or 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
# JRuby 1.6.5 + Java 6 | |
# 01 - Small Array Instantiation | |
# A new, empty array preallocates memory for 16 elements | |
# An array that starts non-empty and is subsequently cleared will only have memory allocated for one element | |
# Ergo, if you know your array will stay small, define with [nil].clear | |
empty_array = [] # 152 bytes | |
cleared_array = [nil].clear # 32 bytes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment