Skip to content

Commit

Permalink
optimize findChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Feb 5, 2019
1 parent 0ff18c0 commit c74a611
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions nodes/ccu-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,15 +894,13 @@ module.exports = function (RED) {
* @returns {String|null}
*/
findChannel(name) {
let found;
Object.keys(this.channelNames).forEach(n => {
if (!found) {
if (this.channelNames[n] === name) {
found = n;
}
const arrChannelNames = Object.keys(this.channelNames);
for (let i = 0, len = arrChannelNames.length; i++; i < len) {
if (this.channelNames[arrChannelNames[i]] === name) {
return arrChannelNames[i];
}
});
return found;
}
return null;
}

/**
Expand Down

0 comments on commit c74a611

Please sign in to comment.