Skip to content

Instantly share code, notes, and snippets.

@mraleph
Created March 4, 2015 19:48
Show Gist options
  • Save mraleph/b9c296b1d41e4079157d to your computer and use it in GitHub Desktop.
Save mraleph/b9c296b1d41e4079157d to your computer and use it in GitHub Desktop.
$ node -e "console.log(process.versions.v8)"
3.14.5.9
$ node bubble.js
81754
$ iojs -e "console.log(process.versions.v8)"
4.1.0.7
$ iojs bubble.js
42165
$ diff -u bubble.js bubble1.js
--- bubble.js 2015-03-04 20:41:08.432717779 +0100
+++ bubble1.js 2015-03-04 20:41:00.028614435 +0100
@@ -6,6 +6,7 @@
function bubble() {
var array = [3,4,1,3,5,1,92,2,4124,424,52,12];
+ array[0] = array[0]; // Work around a COW behavior of the literal.
for (var i = 0; i < array.length; i++) {
for (var y = 0; y < array.length - 1; y++) {
if (array[y+1] < array[y]) {
$ iojs bubble1.js
38854
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment