Comments (5)
I think String
is better than StaticString
, it should in fact be faster.
String
is exactly 2 words wide,StaticString
is 2 words + 1 byte wide (I know, a mistake that's now unfixable with ABI). So passing aStaticString
knocks out 3 registers,String
only 2String
is more powerful thanStaticString
String
also has an "immortal" representation. So if you create aString
that is in fact a static string, it won't allocate and its pointer will go straight into the data section.
@ShivaHuang I would suggest that everybody switch to String
instead of StaticString
. But do you have a concrete logging backend in mind where you'd need to pass file as a StaticString
?
from swift-log.
I'll close this issue.
Thank you @ktoso and @weissi, I learned a lot in this discussion.
from swift-log.
I believe @weissi explored this topic in great depth with specific focus on OSLog so he should be able to answer best here.
from swift-log.
Great point!
I misunderstood the performance and memory usage between String
and StaticString
. And I agree that String
is overall more suitable than StaticString
.
The logging backend use StaticString
I encounter is CocoaLumberjack.
However, after digging into their code, they also convert the StaticString
to String
before passing it to the underlay OC code. here
I think I should submit a PR to CocoaLumberjack for that. ๐
BTW, while searching some similar use case in Apple's SDK, I found some functions use StaticString
for the same propose. like
XCTAssertEqual
fromXCTest
assertionFailure(_:file:line:)
fromSwift Standard Library
Will Apple also change their code? ๐คฃ
from swift-log.
@ShivaHuang until Swift 4.2, StaticString was much faster which is why XCTAssertEqual was designed the way it is. Same for assertionFailure etc, now they canโt easily change that because of source/ABI compat.
Also: StaticString should just be 1 word, thereโs no reason except that nobody noticed until the ABI was fixed ๐ฌ
from swift-log.
Related Issues (20)
- Crash when using error log / Incomplete LogHandler implementation HOT 2
- Infinite recursion between deprecated API's HOT 4
- MultiplexLogHandler to learn about metadata providers
- Add new Discord Logger to README HOT 2
- Make `StdioOutputStream` public HOT 1
- Supported way of accumulating metadata down the callstack HOT 9
- Logging function autoclosures aren't "rethrows" HOT 8
- Simplify logging `Error` types HOT 4
- Support advanced loghandler metadata use cases HOT 2
- Make StreamLogHandler initializers public
- How should I disclose using Swift Log in my iOS app?
- Unsupported runtime for visionOS HOT 1
- Fails to compile on Fedora 39 with Swift 5.8.1 (From repos) or official 5.9 binaries HOT 7
- PrivacyInfo Manifest HOT 2
- visionOS Compatibility HOT 1
- "Unsupported Runtime" when compiling for xrOS HOT 2
- Adding Error to log functions HOT 2
- CoW (copy-on-write) box the `Logger` components (for perf) HOT 2
- .string and .stringConvertable metadata value equality HOT 7
- Build fails when BUILD_LIBRARY_FOR_DISTRIBUTION is set to YES 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 swift-log.