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

possible optimization? #14

Open
zaggino opened this issue May 6, 2015 · 1 comment
Open

possible optimization? #14

zaggino opened this issue May 6, 2015 · 1 comment

Comments

@zaggino
Copy link

zaggino commented May 6, 2015

does it have to read the whole buffer?
https://github.com/aadsm/jschardet/blob/master/src/init.js#L72-L85

if it has to read the whole buffer, can it return a string as a result?

i want to check if file that i've opened is an utf-8 file and then return it further, but I don't want to convert whole buffer to string twice

@aadsm
Copy link
Owner

aadsm commented May 9, 2015

Yes, you are right. There's no technical need to read the entire Buffer into a string. It's done this way because originally this library was only used on the web (before browsers implemented Blobs) and the conversion from Buffer to String was just a quick and dirty port to node.

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