Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Pre-process out assert()
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jan 28, 2011
1 parent 6e53cf8 commit f9f0e5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@
return startup._lazyConstants;
};

var assert;
startup.processAssert = function() {
process.assert = function(x, msg) {
if (!x) {
throw new Error(msg || 'assertion error');
}
// Note that calls to assert() are pre-processed out by JS2C for the
// normal build of node. They persist only in the node_g build.
// Similarly for debug().
assert = process.assert = function(x, msg) {
if (!x) throw new Error(msg || 'assertion error');
};
};

Expand Down Expand Up @@ -229,7 +231,7 @@
process.removeListener = function(type, listener) {
var ret = removeListener.apply(this, arguments);
if (isSignal(type)) {
process.assert(signalWatchers.hasOwnProperty(type));
assert(signalWatchers.hasOwnProperty(type));

if (this.listeners(type).length === 0) {
signalWatchers[type].stop();
Expand Down
1 change: 1 addition & 0 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ def build(bld):
make_macros(macros_loc_debug, "") # leave debug(x) as is in debug build
# replace debug(x) with nothing in release build
make_macros(macros_loc_default, "macro debug(x) = ;\n")
make_macros(macros_loc_default, "macro assert(x) = ;\n")

if not bld.env["USE_DTRACE"]:
make_macros(macros_loc_default, "macro DTRACE_HTTP_SERVER_RESPONSE(x) = ;\n");
Expand Down

0 comments on commit f9f0e5c

Please sign in to comment.