Optimize _.unescape.

This commit is contained in:
John-David Dalton
2013-12-06 09:13:38 -08:00
parent 9a0465eb05
commit 3633d3cd73
9 changed files with 65 additions and 15 deletions

View File

@@ -4686,7 +4686,11 @@
* // => 'Fred, Barney & Pebbles'
*/
function unescape(string) {
return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar);
if (string == null) {
return '';
}
string = String(string);
return string.indexOf(';') < 0 ? string : string.replace(reEscapedHtml, unescapeHtmlChar);
}
/**