Skip to content

Commit

Permalink
Removed few redundant trim()
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanoBalocco committed Apr 27, 2021
1 parent 1f6a385 commit 6dbeb9e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
17 changes: 9 additions & 8 deletions jTDAL.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,32 @@ var jTDAL;
const paths = pathExpression.split('|');
const countFirstLevel = paths.length;
for (let indexFirstLevel = 0; indexFirstLevel < countFirstLevel; ++indexFirstLevel) {
if (regexp['pathString'].exec(paths[indexFirstLevel])) {
const currentPath = paths[indexFirstLevel].trim();
if (regexp['pathString'].exec(currentPath)) {
let compiledString = '';
let index = paths[indexFirstLevel].indexOf('STRING:') + 7;
let index = currentPath.indexOf('STRING:') + 7;
let match = null;
while (null != (match = regexp['pathInString'].exec(paths[indexFirstLevel]))) {
while (null != (match = regexp['pathInString'].exec(currentPath))) {
if (0 < compiledString.length) {
compiledString += '+';
}
if (0 < (match.index - index)) {
compiledString += JSON.stringify(String(paths[indexFirstLevel].substr(index, match.index - index))) + '+';
compiledString += JSON.stringify(String(currentPath.substr(index, match.index - index))) + '+';
}
compiledString += '(' + ParsePath(match[1]) + ')';
index = match['index'] + match[0].length;
}
if (paths[indexFirstLevel].length > index) {
if (currentPath.length > index) {
if (0 < compiledString.length) {
compiledString += '+';
}
compiledString += JSON.stringify(String(paths[indexFirstLevel].substr(index)));
compiledString += JSON.stringify(String(currentPath.substr(index)));
}
returnValue += '(' + compiledString + ')';
break paths;
}
const not = ('!' === paths[indexFirstLevel].trim()[0]);
const path = (not ? paths[indexFirstLevel].trim().substring(1) : paths[indexFirstLevel].trim()).split('/');
const not = ('!' === currentPath[0]);
const path = (not ? currentPath.substring(1) : currentPath).split('/');
if ((0 < path.length) && (0 < path[0].length)) {
switch (path[0]) {
case 'FALSE': {
Expand Down
2 changes: 1 addition & 1 deletion jTDAL.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions jTDAL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,32 @@ namespace jTDAL {
const paths = pathExpression.split( '|' );
const countFirstLevel = paths.length;
for( let indexFirstLevel = 0; indexFirstLevel < countFirstLevel; ++indexFirstLevel ) {
if( regexp[ 'pathString' ].exec( paths[ indexFirstLevel ] ) ) {
const currentPath = paths[ indexFirstLevel ].trim();
if( regexp[ 'pathString' ].exec( currentPath ) ) {
let compiledString = '';
let index = paths[ indexFirstLevel ].indexOf( 'STRING:' ) + 7;
let index = currentPath.indexOf( 'STRING:' ) + 7;
let match = null;
while( null != ( match = regexp[ 'pathInString' ].exec( paths[ indexFirstLevel ] ) ) ) {
while( null != ( match = regexp[ 'pathInString' ].exec( currentPath ) ) ) {
if( 0 < compiledString.length ) {
compiledString += '+';
}
if( 0 < ( match.index - index ) ) {
compiledString += JSON.stringify( String( paths[ indexFirstLevel ].substr( index, match.index - index ) ) ) + '+';
compiledString += JSON.stringify( String( currentPath.substr( index, match.index - index ) ) ) + '+';
}
compiledString += '(' + ParsePath( match[ 1 ] ) + ')';
index = match[ 'index' ] + match[ 0 ].length;
}
if( paths[ indexFirstLevel ].length > index ) {
if( currentPath.length > index ) {
if( 0 < compiledString.length ) {
compiledString += '+';
}
compiledString += JSON.stringify( String( paths[ indexFirstLevel ].substr( index ) ) );
compiledString += JSON.stringify( String( currentPath.substr( index ) ) );
}
returnValue += '(' + compiledString + ')';
break paths;
}
const not = ( '!' === paths[ indexFirstLevel ].trim()[ 0 ] );
const path = ( not ? paths[ indexFirstLevel ].trim().substring( 1 ) : paths[ indexFirstLevel ].trim() ).split( '/' );
const not = ( '!' === currentPath[ 0 ] );
const path = ( not ? currentPath.substring( 1 ) : currentPath ).split( '/' );
if( ( 0 < path.length ) && ( 0 < path[ 0 ].length ) ) {
switch( path[ 0 ] ) {
case 'FALSE': {
Expand Down

0 comments on commit 6dbeb9e

Please sign in to comment.