Comments (5)
The functions that return an error are not meant to process truncated inputs, they are meant to help identify genuine errors. If you have simply a truncated input, the simplest strategy is to roll it back to the previous complete character.
Please see #349
I have added convenience functions.
from simdutf.
Yes, pre-trimming is also an option, however in my use case, truncated final character should be rare, as such I was hoping to avoid the cost of reading the last 3 bytes on every chunk. Are you saying that I cannot rely on the function returning an error in case of truncated last char? My potential algorithm was run the simd transcode function, if there is a TOO_SHORT error trim the last char and re-run.
Thanks for the convenience function.
from simdutf.
I was hoping to avoid the cost of reading the last 3 bytes on every chunk.
It is very cheap unless you are processing tiny pieces, in which case, you have other performance constraints.
Are you saying that I cannot rely on the function returning an error in case of truncated last char?
It will return an error. The error should be TOO_SHORT, as you indicated.
My potential algorithm was run the simd transcode function, if there is a TOO_SHORT error trim the last char and re-run.
That's likely slower than what I propose if you expect that the input is valid.
from simdutf.
That's likely slower than what I propose if you expect that the input is valid.
I dont know if the input is valid, it could be invalid and have a trailing truncated char as well. Therefore, I have to use the function that returns an error anyway. Thus, given that a trailing truncated char is rare pre-trimming cannot be faster. But anyway, that's easily checked by measuring.
I was just hoping to convince you to add a field to the return struct indicating how much was output before the error was encountered. But I can work with the existing API, given truncated trailer is rare for me, trascode, check error return, strip trailer, re-transcode should not be too bad. I will benchmark and see.
from simdutf.
@kovidgoyal Yes, you want support for decoding invalid inputs. It is not something simdutf supports at this time. The assumption is that the input is valid. We'll extend the library at some point in the future to include support for invalid inputs.
from simdutf.
Related Issues (20)
- Use fmtlib where appropriate
- create higher level base64 functions HOT 4
- Incorrect processor detection when cross compiling HOT 2
- RVV port for Base64 procedures HOT 4
- RISC-V RVV CI tests broken
- Base64 decoder is currently too lenient with padding characters
- `simdutf::result` constructor is not implemented HOT 4
- SIMDUTF_CAN_ALWAYS_RUN_* macros broken HOT 2
- Crosscompilation for RVV failed HOT 3
- CI: run tests in parallel for all targets HOT 2
- Compiler failure on ARM64 Windows HOT 7
- Possible Issue With .pc.in? HOT 7
- Crash on Windows when main thread exits while a different thread is using simdutf HOT 1
- tests/reference /validate_latin1 implemented incorrectly HOT 13
- UTF-32 endian support HOT 2
- #include inside namespace breaks symbols for regular use on riscv64 HOT 2
- Build failures due to forcing AVX512 types on an AVX2 system HOT 1
- Add fast function to characterize a UTF-8 string HOT 3
- warning with gcc14 on c++20 mode : warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor] HOT 5
- Constant-time base64 decoder HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simdutf.