Last active
December 20, 2015 02:29
-
-
Save jkutner/6056579 to your computer and use it in GitHub Desktop.
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
i = size+1 | |
realloc(i) | |
set(i, val) |
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
config.filter_parameters += [:password] |
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
data << m * n |
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
class ExpensiveToCreate | |
def self.instance | |
@instance ||= ExpensiveToCreate.new | |
end | |
end |
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
$ jrlint | |
… | |
./config/application.rb:54: [nonatomic, warning] Non-local operator assignment is not guaranteed to be atomic |
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 threads.rb | |
size => 182 |
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
$ ruby threads.rb | |
size => 256 |
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
/** rb_ary_push - specialized rb_ary_store | |
* | |
*/ | |
@JRubyMethod(name = "<<", required = 1) | |
public RubyArray append(IRubyObject item) { | |
modify(); | |
int valuesLength = values.length - begin; | |
if (realLength == valuesLength) { | |
if (realLength == Integer.MAX_VALUE) throw getRuntime().newArgumentError("index too big"); | |
long newLength = valuesLength + (valuesLength >> 1); | |
if (newLength > Integer.MAX_VALUE) { | |
newLength = Integer.MAX_VALUE; | |
} else if (newLength < ARRAY_DEFAULT_SIZE) { | |
newLength = ARRAY_DEFAULT_SIZE; | |
} | |
realloc((int) newLength, valuesLength); | |
} | |
safeArraySet(values, begin + realLength++, item); | |
return this; | |
} |
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
data = [] | |
threads = [] | |
16.times do |m| | |
threads << Thread.new do | |
16.times do |n| | |
data << m * n | |
end | |
end | |
end | |
threads.map(&:join) | |
puts "size => #{data.size}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment