| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,3 @@ | ||
| 'use strict'; | ||
|
|
||
| // This is a free list to avoid creating so many of the same object. | ||
| exports.FreeList = function(name, max, constructor) { | ||
| this.name = name; | ||
| this.constructor = constructor; | ||
| this.max = max; | ||
| this.list = []; | ||
| }; | ||
|
|
||
|
|
||
| exports.FreeList.prototype.alloc = function() { | ||
| //debug("alloc " + this.name + " " + this.list.length); | ||
| return this.list.length ? this.list.shift() : | ||
| this.constructor.apply(this, arguments); | ||
| }; | ||
|
|
||
|
|
||
| exports.FreeList.prototype.free = function(obj) { | ||
| //debug("free " + this.name + " " + this.list.length); | ||
| if (this.list.length < this.max) { | ||
| this.list.push(obj); | ||
| return true; | ||
| } | ||
| return false; | ||
| }; | ||
| module.exports = require('internal/freelist'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| 'use strict'; | ||
|
|
||
| // This is a free list to avoid creating so many of the same object. | ||
| exports.FreeList = function(name, max, constructor) { | ||
| this.name = name; | ||
| this.constructor = constructor; | ||
| this.max = max; | ||
| this.list = []; | ||
| }; | ||
|
|
||
|
|
||
| exports.FreeList.prototype.alloc = function() { | ||
| return this.list.length ? this.list.shift() : | ||
| this.constructor.apply(this, arguments); | ||
| }; | ||
|
|
||
|
|
||
| exports.FreeList.prototype.free = function(obj) { | ||
| if (this.list.length < this.max) { | ||
| this.list.push(obj); | ||
| return true; | ||
| } | ||
| return false; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -69,6 +69,8 @@ | |
| 'lib/v8.js', | ||
| 'lib/vm.js', | ||
| 'lib/zlib.js', | ||
|
|
||
| 'lib/internal/freelist.js', | ||
| ], | ||
| }, | ||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| module.exports = require('internal/freelist'); | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // Flags: --expose_internals | ||
|
|
||
| var common = require('../common'); | ||
| var assert = require('assert'); | ||
|
|
||
| assert.equal(typeof require('internal/freelist').FreeList, 'function'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| var common = require('../common'); | ||
| var assert = require('assert'); | ||
|
|
||
| assert.throws(function() { | ||
| require('internal/freelist'); | ||
| }); | ||
|
|
||
| assert(require('../fixtures/internal-modules') === 42); |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityShouldn't this file be called freelist.js or something? Avoids unnecessary churn when another module is added.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNot sure what do you mean. js2c drops extensions so this is how we require internal modules. This particular test checks that if we try it in userland module and there is node_modules/internal/freelist.js everything works as before.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe directory is called test/fixtures/internal-modules but it's really only about the freelist module. Maybe move index.js to test/fixtures/internal-modules/freelist?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitydoesn't change a lot. we only need to test this once with any module. it could be anything other than freelist
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.