Comments (6)
My reasoning is that I don't see any other way to get rid of the ICU dependency, is it what's actually being used for re-encoding?
Re-encoding doesn't require ICU because it can be done with TextEncoder and TextDecoder in JavaScript.
And as far as I know, ICU is only used to get extra character info (e.g. isEmoji
or equality checking with normalization)
I think keeping default encoding as UTF8 can be accomplished with "no-ICU mode"
from javascriptkit.
Have you tried using something like String(utf16CodeUnits: UnsafePointer<unichar>, count: Int)
to create a string from binary data (and string.utf16
/string.withCString
to send it the other way) instead? Or does that still do the extra work of re-encoding?
Another idea: since many strings (especially object keys) are ASCII, would it be possible to have a second string type that only supports ASCII and is faster to decode?
from javascriptkit.
I'm not sure how to get utf16 byte sequence from JavaScript String and create JavaScript String from utf16 byte sequence without re-encoding.
from javascriptkit.
Starting with Swift 5 it's UTF-8 under the hood anyway, if I understand correctly. I think we'd need to patch stdlib to either allow both encodings, or to entirely force it to use UTF-16 when targeting WebAssembly.
from javascriptkit.
IMO, I don't want to change the default encoding. I think it's a too big change and the change improve performance only when running on JavaScript environment.
My idea is keeping the Swift side encoding way and reduce re-encoding opportunities.
from javascriptkit.
My reasoning is that I don't see any other way to get rid of the ICU dependency, is it what's actually being used for re-encoding? I'd be surprised if it can become smaller than 100kb even after optimizations. Maybe we could add a compiler flag or something that sets the default encoding on per-build basis rather than the whole Wasm/WASI platform? Otherwise how can we ever become competitive to AssemblyScript, which has a mere 2kb overhead in its full runtime? I know that AssemblyScript is very minimalistic, I only wish one could strip Swift runtime similarly as much as possible not by default, but only if they want to achieve the same minimalism in their SwiftWasm apps.
Another idea is to keep String
UTF-8, but allow StaticString
to use UTF-16, or maybe introduce some other way to specify a UTF-16 literal? The reasoning is that Text
and other types that rely on strings in Tokamak could avoid using UTF-8 String
altogether, take that UTF-16 literal and pass it directly to JSString
.
from javascriptkit.
Related Issues (20)
- Use FinalizationRegistry to auto-deinit Closures HOT 3
- Cannot set HTMLElement.style properties HOT 2
- Calling `sleep()` causes `TypeError: can't convert null to BigInt`
- Enchancement: Add a link to the docs HOT 4
- Export function returning a JSValue HOT 2
- Arguments in JSClosure HOT 4
- JSPromise(resolver:) usage HOT 3
- Asynchronous calls in JSClosure HOT 5
- Making JSObject hashable HOT 5
- Compile error on macOS 12.2.1 HOT 6
- UserAgent support? HOT 1
- WebSockets implementation HOT 2
- Generate JavaScriptKit `.js` runtime with SwiftPM build tool HOT 6
- `JSNumber` type to support `long long` type in Web API IDL
- PUT request using Fetch HOT 2
- Occasional JSClosure has been already released by Swift side HOT 4
- Compiled module was created by a different version of the compiler; rebuild 'JavaScriptKit' and try again HOT 2
- Cannot perform DataView.prototype.setBigUint64 on a detached ArrayBuffer HOT 2
- JSClosure will be overriden from other closure HOT 1
- Are JSValue bitmasks possible? HOT 2
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 javascriptkit.