Skip to content

Commit a223833

Browse files
author
Juriy Zaytsev
committed
Minor optimization with property access.
1 parent 6527566 commit a223833

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lang/string.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ Object.extend(String.prototype, (function() {
253253
(e.g. background-color -> backgroundColor) so we take advantage of caching
254254
*/
255255

256-
var camelizeCache = { };
256+
var camelizeCache = { }, cached;
257257
function camelize() {
258-
if (typeof camelizeCache[this] == 'string') {
259-
return camelizeCache[this];
258+
if (typeof (cached = camelizeCache[this]) == 'string') {
259+
return cached;
260260
}
261261
var parts = this.split('-'), len = parts.length;
262262
if (len == 1) return parts[0];
@@ -276,10 +276,10 @@ Object.extend(String.prototype, (function() {
276276
*
277277
* Capitalizes the first letter of a string and downcases all the others.
278278
**/
279-
var capitalizeCache = { };
279+
var capitalizeCache = { }, cached;
280280
function capitalize() {
281-
if (typeof capitalizeCache[this] == 'string') {
282-
return capitalizeCache[this];
281+
if (typeof (cached = capitalizeCache[this]) == 'string') {
282+
return cached;
283283
}
284284
return (capitalizeCache[this] = this.charAt(0).toUpperCase() + this.substring(1).toLowerCase());
285285
}

0 commit comments

Comments
 (0)