Comments (3)
I don't think it is actually possible to calculate cap()
on demand, because it can be set to an arbitrary value: consider slice[:5:7]
, which sets len
to 5 and cap
to 7 no matter what they were before.
In general, I think the compiler will be able to optimize cap
away in trivial cases where it is never used (no append
or cap
call). This will probably improve once I get around to splitting the slice struct into independent variables in function calls etc. which LLVM is better at optimizing away.
from tinygo.
Is this issue still relevant given all of the internal changes to TinyGo, or should it be closed?
from tinygo.
I don't think there is anything I can do here. I don't see a way to perform this optimization while still adhering to the Go language specification. Additionally, slices in local variables and function parameters are easily optimized by LLVM: function parameters are split up in #20 and local variables are split up by LLVM. Unnecessary copies are usually avoided by dead code elimination passes and the deadargelim pass. This means that the cap
part of a slice is often already eliminated.
If there is something I'm missing I'd like to know about it. For now, I'm going to close the issue.
from tinygo.
Related Issues (20)
- Build fails with: "ld.lld: error: undefined symbol" HOT 7
- wdk HOT 1
- type C.bool is undfined HOT 4
- Is it possible upgrade firmware online to STM32F4xx by Tinygo? HOT 2
- multiple assignment statements executed in the wrong order HOT 5
- Wasm inside vscode extension
- "-tags" option should support a comma separated list. HOT 2
- wasmtime v14 breaks `-target=wasi` HOT 4
- Validating signature of JWT gives `undefined symbol: crypto/internal/bigmod.addMulVVW1024` HOT 2
- Xtensa: unable to compile code that needs clang headers HOT 3
- Windows release missing wasm-opt.exe (0.30.0 zip download)
- undefined symbol crypto/internal/bigmod.addMul HOT 2
- mingw expected in incorrect location (tinygo-macos) HOT 1
- Playdate support
- UART for nrf targets does not implement `machine.Serialer` HOT 2
- Error while compiling http proxy server into wasm
- IsExported undefined (type reflect.Method has no field or method IsExported)
- "Uncaught (in promise) TypeError: wasm function signature contains illegal type" in chrome 84
- What kind of GC is `-gc=precise`?
- TinyGo for ESP32 on Windows 10 - not compiling 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 tinygo.