mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 23:13:40 +00:00
all: modernize (#5498)
* modernize string cut usage * modernize string cut prefix usage * modernize slices helper usage * modernize min and max usage * modernize loop variable copies * modernize integer range loops * modernize map copy loops * modernize go types iterator usage * modernize empty interface usage * modernize atomic type usage * modernize string builders * modernize string split iteration * modernize remaining loop variable copies * modernize usb cdc min usage * modernize src integer range loops * modernize example empty interface usage * modernize src min and max usage * modernize src integer range loops * modernize src empty interface usage * modernize src atomic type usage * modernize reflect type lookups * modernize review nits
This commit is contained in:
@@ -150,11 +150,11 @@ func (p *lowerInterfacesPass) run() error {
|
||||
|
||||
// Collect all type codes.
|
||||
for global := p.mod.FirstGlobal(); !global.IsNil(); global = llvm.NextGlobal(global) {
|
||||
if strings.HasPrefix(global.Name(), "reflect/types.type:") {
|
||||
if after, ok := strings.CutPrefix(global.Name(), "reflect/types.type:"); ok {
|
||||
// Retrieve Go type information based on an opaque global variable.
|
||||
// Only the name of the global is relevant, the object itself is
|
||||
// discarded afterwards.
|
||||
name := strings.TrimPrefix(global.Name(), "reflect/types.type:")
|
||||
name := after
|
||||
if _, ok := p.types[name]; !ok {
|
||||
t := &typeInfo{
|
||||
name: name,
|
||||
@@ -463,7 +463,7 @@ func (p *lowerInterfacesPass) addTypeMethods(t *typeInfo, methodSet llvm.Value)
|
||||
signatures := p.builder.CreateExtractValue(set, 1, "")
|
||||
wrappers := p.builder.CreateExtractValue(set, 2, "")
|
||||
numMethods := signatures.Type().ArrayLength()
|
||||
for i := 0; i < numMethods; i++ {
|
||||
for i := range numMethods {
|
||||
signatureGlobal := p.builder.CreateExtractValue(signatures, i, "")
|
||||
function := p.builder.CreateExtractValue(wrappers, i, "")
|
||||
function = stripPointerCasts(function) // strip bitcasts
|
||||
@@ -489,7 +489,7 @@ func (p *lowerInterfacesPass) addInterface(methodsString string) {
|
||||
signatures: make(map[string]*signatureInfo),
|
||||
}
|
||||
p.interfaces[methodsString] = t
|
||||
for _, method := range strings.Split(methodsString, "; ") {
|
||||
for method := range strings.SplitSeq(methodsString, "; ") {
|
||||
signature := p.getSignature(method)
|
||||
signature.interfaces = append(signature.interfaces, t)
|
||||
t.signatures[method] = signature
|
||||
@@ -683,7 +683,7 @@ func (p *lowerInterfacesPass) extractMethodSigs(field llvm.Value) []string {
|
||||
methodArray := p.builder.CreateExtractValue(field, 1, "")
|
||||
n := methodArray.Type().ArrayLength()
|
||||
sigs := make([]string, 0, n)
|
||||
for j := 0; j < n; j++ {
|
||||
for j := range n {
|
||||
sig := p.builder.CreateExtractValue(methodArray, j, "")
|
||||
sig = stripPointerCasts(sig)
|
||||
sigs = append(sigs, sig.Name())
|
||||
@@ -727,7 +727,7 @@ func (p *lowerInterfacesPass) filterMethodSet(field llvm.Value, keepSigs map[str
|
||||
}
|
||||
entries := make([]methodEntry, numMethods)
|
||||
nameSet := make(map[string]struct{}, numMethods)
|
||||
for j := 0; j < numMethods; j++ {
|
||||
for j := range numMethods {
|
||||
sig := p.builder.CreateExtractValue(methodArray, j, "")
|
||||
stripped := stripPointerCasts(sig)
|
||||
name := stripped.Name()
|
||||
|
||||
Reference in New Issue
Block a user