diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-09 03:39:13 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-09 03:39:13 +0000 |
commit | bf8b58267edaca28b2306da5300431e5a049896f (patch) | |
tree | 1b71c85f52715dc15369388174fd82f97a39b08f /sca-cpp/trunk/modules/js/htdocs/util.js | |
parent | 2e9c610931b4e0a6bab25b1fe5dbd0def45ee126 (diff) |
Add a composite similar to the travel tutorial app to the sample dashboard. Minor Javascript performance improvements to speed up the layout of big composites.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1056881 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/js/htdocs/util.js')
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/util.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sca-cpp/trunk/modules/js/htdocs/util.js b/sca-cpp/trunk/modules/js/htdocs/util.js index 0f966b180e..b90c96db2d 100644 --- a/sca-cpp/trunk/modules/js/htdocs/util.js +++ b/sca-cpp/trunk/modules/js/htdocs/util.js @@ -65,14 +65,8 @@ function reverse(l) { } function isNil(v) { - if (v == null) + if (v == null || typeof v == 'undefined' || (v.constructor == Array && v.length == 0)) return true; - if ('' + v == 'undefined') - return true; - try { - if (isList(v) && v.length == 0) - return true; - } catch (e) {} return false; } @@ -89,10 +83,8 @@ function isString(v) { } function isList(v) { - try { - if (v.constructor == Array) - return true; - } catch (e) {} + if (v != null && typeof v != 'undefined' && v.constructor == Array) + return true; return false; } @@ -102,7 +94,11 @@ function isTaggedList(v, t) { return false; } +var emptylist = new Array(); + function mklist() { + if (arguments.length == 0) + return emptylist; var a = new Array(); for (i = 0; i < arguments.length; i++) a[i] = arguments[i]; @@ -206,3 +202,12 @@ function writeValue(v) { return '(' + writeValue(car(v)) + writeList(cdr(v)) + ')'; } +/** + * Apply a function and memoize its result. + */ +function memo(obj, key, f) { + if (obj[key]) + return obj[key]; + return obj[key] = f(); +} + |