Lazy load crypto
authorRyan Dahl <ry@tinyclouds.org>
Tue, 4 May 2010 21:21:01 +0000 (14:21 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Tue, 4 May 2010 21:21:14 +0000 (14:21 -0700)
The whole program is being slowed down by the large CA string in crypto.
Why?

lib/net.js

index 40b6745..5849401 100644 (file)
@@ -1,7 +1,6 @@
 var sys = require("sys");
 var fs = require("fs");
 var events = require("events");
-var crypto= require("crypto");
 var dns = require('dns');
 
 var kMinPoolSpace = 128;
@@ -422,6 +421,7 @@ Stream.prototype.setSecure = function(credentials) {
   if (!have_crypto) {
     throw new Error('node.js not compiled with openssl crypto support.');
   }
+  var crypto= require("crypto");
   this.secure = true;
   this.secureEstablished = false;
   // If no credentials given, create a new one for just this Stream