Skip to content

Commit 391a297

Browse files
Remove unnecessary 'fixed' statement (#13146)
Part of the "remove unsafe" campaign. This call site was flagged by an experimental rule as being a good candidate for removing the `fixed` keyword and using standard array iteration. There's still obviously unsafe code in this method, but we're working in baby steps. :) The experimental rule was looking only for low-hanging fruit and did not identify any other good candidates in this repo at this time. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/13146)
2 parents 7b4d380 + 7b2aa63 commit 391a297

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,9 @@ public EncoderParameter(Encoder encoder, long[] value)
214214
_parameterValue = Marshal.AllocHGlobal(checked(_numberOfValues * sizeof(int)));
215215

216216
int* dest = (int*)_parameterValue;
217-
fixed (long* source = value)
217+
for (int i = 0; i < value.Length; i++)
218218
{
219-
for (int i = 0; i < value.Length; i++)
220-
{
221-
dest[i] = (int)source[i];
222-
}
219+
dest[i] = (int)value[i];
223220
}
224221

225222
GC.KeepAlive(this);

0 commit comments

Comments
 (0)