[Pkg-javascript-commits] [node-iconv-lite] 64/83: Make require('iconv-lite') fast
matthew pideil
mpideil-guest at moszumanska.debian.org
Tue Apr 1 19:56:52 UTC 2014
This is an automated email from the git hooks/post-receive script.
mpideil-guest pushed a commit to branch master
in repository node-iconv-lite.
commit 11a70e991a25b5c5617431bbad2563342b9d2e39
Author: Lee Treveil <leetreveil at gmail.com>
Date: Sun May 19 23:48:01 2013 +0100
Make require('iconv-lite') fast
---
index.js | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/index.js b/index.js
index adec5dd..92eb818 100644
--- a/index.js
+++ b/index.js
@@ -9,9 +9,17 @@ var iconv = module.exports = {
defaultCharUnicode: '�',
defaultCharSingleByte: '?',
+
+ encodingsLoaded: false,
// Get correct codec for given encoding.
getCodec: function(encoding) {
+ if (!iconv.encodingsLoaded) {
+ applyEncodings(require('./encodings/singlebyte'));
+ applyEncodings(require('./encodings/gbk'));
+ applyEncodings(require('./encodings/big5'));
+ iconv.encodingsLoaded = true;
+ }
var enc = encoding || "utf8";
var codecOptions = undefined;
while (1) {
@@ -192,9 +200,6 @@ function applyEncodings(encodings) {
iconv.encodings[key] = encodings[key]
}
-applyEncodings(require('./encodings/singlebyte'));
-applyEncodings(require('./encodings/gbk'));
-applyEncodings(require('./encodings/big5'));
// Utilities
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-iconv-lite.git
More information about the Pkg-javascript-commits
mailing list