I am a hobbyist reverse engineer and a software security enthusiast. I like to break things in order to gain knowledge about their inner workings ๐
I am currently experimenting with the C language and sometime with the Dart language ๐ฏ
FNV hash algorithm for Dart language
Home Page: https://pub.dev/packages/fnv
License: MIT License
I tried to compile the web platform, but got the following error.
/C:/Users/Admin/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/fnv-1.0.1/lib/src/fnv_constants.dart:3:26: Error: The integer literal 0xcbf29ce484222325 can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in JavaScript. In JavaScript 0xcbf29ce484222000 is the nearest value that can be represented exactly.
const int FNV1_64_INIT = 0xcbf29ce484222325;
^^^^^^^^^^^^^^^^^^
/C:/Users/Admin/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/fnv-1.0.1/lib/src/fnv_constants.dart:10:25: Error: The integer literal 0xffffffffffffffff can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in JavaScript. In JavaScript 0x10000000000000000 is the nearest value that can be represented exactly.
const int UINT64_MASK = 0xffffffffffffffff;
^^^^^^^^^^^^^^^^^^
Failed to compile application.
Hi there,
Thanks for the package.
I noticed that the package hashes strings by UTF8 encoding them first. Have you considered using String.codeUnits
instead?
codeUnits
is the string's backing data structure, so nothing has to be computed. I put together a quick benchmark and it's considerably faster:
https://gist.github.com/shyndman/3b73ec340fa6e4ea8e4b510bf9bb0d3f
Hello again,
I decided to try out hinting the compiler to inline the package's hash functions by using @pragma('vm:prefer-inline')
, and it appears to have yielded a pretty substantial improvement in performance, at least in a Dart AOT build (VM build appears unaffected).
Would you be open to a PR?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.