mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-06-02 22:08:36 -05:00
More efficient toId implementation
This commit is contained in:
parent
cae58c2fde
commit
fd512f4fc4
6
app.js
6
app.js
|
|
@ -257,12 +257,10 @@ if (config.protocol === 'io') {
|
|||
* Otherwise, an empty string will be returned.
|
||||
*/
|
||||
toId = function(text) {
|
||||
if (typeof text === 'number') text = ''+text;
|
||||
if (text && text.id) text = text.id;
|
||||
else if (text && text.userid) text = text.userid;
|
||||
text = string(text);
|
||||
if (typeof text !== 'string') return ''; //???
|
||||
return text.toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
|
||||
return string(text).toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
};
|
||||
toUserid = toId;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,11 +30,10 @@ if (config.crashguard) {
|
|||
* Otherwise, an empty string will be returned.
|
||||
*/
|
||||
toId = function(text) {
|
||||
if (typeof text === 'number') text = ''+text;
|
||||
if (text && text.id) text = text.id;
|
||||
text = string(text);
|
||||
if (typeof text !== 'string') return ''; //???
|
||||
return text.toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
else if (text && text.userid) text = text.userid;
|
||||
|
||||
return string(text).toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
};
|
||||
toUserid = toId;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user