Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is crc32 realy needed? #161

Closed
kroleg opened this issue Dec 18, 2018 · 1 comment
Closed

Is crc32 realy needed? #161

kroleg opened this issue Dec 18, 2018 · 1 comment

Comments

@kroleg
Copy link
Contributor

kroleg commented Dec 18, 2018

Currently to check if session changed koa-session does these:

  1. calculates crc of JSON.stringify'ed session data when it reads session from cookie/external storage
    this.prevHash = util.hash(this.session.toJSON());

    this.prevHash = util.hash(this.session.toJSON());

    return crc(JSON.stringify(sess));
  2. it calculates crc of session before commiting it and then compares new sum with old one.

So if instead of crc as a hash we will use result of JSON.stringify (i.e. const hash = (sess) => JSON.stringify(sess)) we can shave of some time from request/response processing. Not much, but it will be -1 dependency. Not sure if memory consumption will increase, i think it depends on garbage collection.

Resolves #131 and #156 (no need in faster crc calculator)

@oalieno
Copy link

oalieno commented Feb 23, 2019

I'm also wondering why do we need crc32.
crc32 is used for error detection.
Simply compare the string will work.

@kroleg kroleg closed this as completed Apr 1, 2024
@kroleg kroleg closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
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

No branches or pull requests

2 participants