Skip to content

Conversation

meetall
Copy link
Contributor

@meetall meetall commented May 28, 2018

Backslash characters #8

@meetall meetall mentioned this pull request May 28, 2018
@coveralls
Copy link

coveralls commented May 28, 2018

Pull Request Test Coverage Report for Build 44

  • 17 of 17 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 95.495%

Totals Coverage Status
Change from base Build 42: 0.2%
Covered Lines: 290
Relevant Lines: 301

💛 - Coveralls

@meetall
Copy link
Contributor Author

meetall commented May 28, 2018

em... not sure why build is failing on old version of node. I haven't change the package.json file and couldn't reproduce it either locally. I'll try to resolve it

@meetall
Copy link
Contributor Author

meetall commented May 28, 2018

i try to build it again and it passes with one restart. https://travis-ci.org/meetall/nimnjs-node could you please restart the build for the failed node versions? thanks

Copy link
Member

@amitguptagwl amitguptagwl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I haven't reviewed the whole code, I believe you would like to replace forward slash with backslash. ''.

src/decoder.js Outdated

for(;this.index < len && until.indexOf(this.currentChar()) === -1;this.index++);
for(;this.index < len; this.index++){
if(this.currentChar() === '/' && this.index+1 < len
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be ''?

src/encoder.js Outdated
function sanitizeData(data) {
if(typeof data === "string"){
appCharsArr.forEach(c => {
data = data.replace(new RegExp(c, 'g'), '/'+c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be ''?

@meetall
Copy link
Contributor Author

meetall commented May 30, 2018

yes, I'll update the forward slashes to backslash. Thanks for spotting. For the single quote and double quote issue, I thought both works in javascript? But I can change them to double quote if you want to keep some convention in the code.

@amitguptagwl
Copy link
Member

@meetall Umm no actually git has removed backslash char from my comment. I wanted to say should it be '\'?

Using single quote is better but double quote will also work. So that's not the big problem.

@meetall
Copy link
Contributor Author

meetall commented May 30, 2018

@amitguptagwl Updated now

@amitguptagwl
Copy link
Member

My apologies for the delay. But I'm quite busy with some other tasks. I'll do it ASAP.

Copy link
Member

@amitguptagwl amitguptagwl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for late review. I believe the encoding process can be improve little bit by using range match. Please check

src/encoder.js Outdated
function sanitizeData(data) {
if(typeof data === "string"){
appCharsArr.forEach(c => {
data = data.replace(new RegExp(c, 'g'), '\\'+c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this loop can be avoided with range match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated now

src/encoder.js Outdated
appCharsArr.forEach(c => {
data = data.replace(new RegExp(c, 'g'), '\\'+c);
})
let regex = new RegExp(appCharsArr.join('|'), 'g');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to create the regex on every function call? I believe it'll impact the performance too.

Copy link
Member

@amitguptagwl amitguptagwl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for all the revisions but performance is one of the important concerns of this project.

Can you please check if there is any other change which may impact the performance?

@meetall
Copy link
Contributor Author

meetall commented Jun 7, 2018 via email

@meetall
Copy link
Contributor Author

meetall commented Jun 9, 2018

Hello, I made the update you suggested and did some research as well. But couldn't figure out any other improvement.

The actual code change in this PR is quite minor (basically "replace" and "substr"). I can see you have another issue in the backlog to improve the algorithm. Maybe it could be re-evaluated as a whole.

I also looked into some javascript profiling tool but all of them are for node web applications. Do you have any plans to add performance test if it is a critical factor?

@amitguptagwl amitguptagwl merged commit a98f19a into NaturalIntelligence:master Jun 9, 2018
@amitguptagwl
Copy link
Member

Performance is really important. Hence I'm rewriting the whole algorithm. I'm almost finished and will publish it tomorrow. Let's see how much we achieve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants