Skip to content

Commit

Permalink
Optimized validationTopic
Browse files Browse the repository at this point in the history
  • Loading branch information
gnought committed Sep 14, 2019
1 parent 24b73f5 commit efa65d0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/handlers/validations.js
@@ -1,13 +1,17 @@
'use strict'

function validateTopic (topic, message) {
var end = topic.length - 1
var endMinus = end - 1
var slashInPreEnd = endMinus > 0 && topic.charCodeAt(endMinus) !== 47
if (topic.length === 0) {
var tlen = topic.length

if (tlen === 0) {
return new Error('impossible to ' + message + ' to an empty topic')
}
for (var i = 0; i < topic.length; i++) {

var end = tlen - 1
var endMinus = end - 1
var slashInPreEnd = endMinus > 0 && topic.charCodeAt(endMinus) !== 47

for (var i = 0; i < tlen; i++) {
switch (topic.charCodeAt(i)) {
case 35:
var notAtTheEnd = i !== end
Expand Down

0 comments on commit efa65d0

Please sign in to comment.