aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/d-codegen.cc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-06-23 10:46:52 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2021-04-06 19:43:31 +0200
commit62321ab477e2bdc3450b14662b9a7d3b9d3c9d1f (patch)
tree81deb163d08a0648a21a624d79ed696d1d163f43 /gcc/d/d-codegen.cc
parent4993d0265ef8ff1a75dfb86cd6da95ccc7fa6328 (diff)
downloadgcc-62321ab477e2bdc3450b14662b9a7d3b9d3c9d1f.zip
gcc-62321ab477e2bdc3450b14662b9a7d3b9d3c9d1f.tar.gz
gcc-62321ab477e2bdc3450b14662b9a7d3b9d3c9d1f.tar.bz2
d: Use Array::find to get index of element
gcc/d/ChangeLog: * d-codegen.cc (build_frame_type): Use Array::find to get index of element.
Diffstat (limited to 'gcc/d/d-codegen.cc')
-rw-r--r--gcc/d/d-codegen.cc28
1 files changed, 10 insertions, 18 deletions
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 608abcd..5fa1acd 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2507,15 +2507,11 @@ build_frame_type (tree ffi, FuncDeclaration *fd)
{
VarDeclaration *v = (*fd->parameters)[i];
/* Remove if already in closureVars so can push to front. */
- for (size_t j = i; j < fd->closureVars.length; j++)
- {
- Dsymbol *s = fd->closureVars[j];
- if (s == v)
- {
- fd->closureVars.remove (j);
- break;
- }
- }
+ size_t j = fd->closureVars.find (v);
+
+ if (j < fd->closureVars.length)
+ fd->closureVars.remove (j);
+
fd->closureVars.insert (i, v);
}
}
@@ -2523,15 +2519,11 @@ build_frame_type (tree ffi, FuncDeclaration *fd)
/* Also add hidden `this' to outer context. */
if (fd->vthis)
{
- for (size_t i = 0; i < fd->closureVars.length; i++)
- {
- Dsymbol *s = fd->closureVars[i];
- if (s == fd->vthis)
- {
- fd->closureVars.remove (i);
- break;
- }
- }
+ size_t i = fd->closureVars.find (fd->vthis);
+
+ if (i < fd->closureVars.length)
+ fd->closureVars.remove (i);
+
fd->closureVars.insert (0, fd->vthis);
}
}