Skip to content

Commit 0109970

Browse files
authored
Optimize, simplify FromChunkedBase64String method (#1868)
This update optimizes and simplifies the FromChunkedBase64String method, improving both performance and memory efficiency. ### Implementation Details Removed unnecessary manual handling of \r and \n, as Convert.FromBase64String already handles these characters automatically. Eliminated Where() and ToArray() operations, significantly reducing memory allocations and improving execution efficiency. ### Benchmark Results Performance: ~2.4x speed improvement Memory Usage: ~70% reduction
1 parent dc006e0 commit 0109970

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/DocumentFormat.OpenXml.Framework/Packaging/FlatOpcExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ private static byte[] FromChunkedBase64String(string? chunkedBase64String)
245245
return Cached.Array<byte>();
246246
}
247247

248-
var base64CharArray = chunkedBase64String.Where(c => c is not '\r' and not '\n').ToArray();
249-
return Convert.FromBase64CharArray(base64CharArray, 0, base64CharArray.Length);
248+
return Convert.FromBase64String(chunkedBase64String);
250249
}
251250
}

0 commit comments

Comments
 (0)