From 181ba25a45de3663d5e50b1b22a3545f82324b70 Mon Sep 17 00:00:00 2001 From: Etienne Cimon Date: Mon, 16 Jul 2018 14:21:49 -0400 Subject: [PATCH] Avoid costly misalignment checks during array cast when all testing is said and done and performance becomes critical (When no bounds checks are asked for) --- src/rt/arraycast.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rt/arraycast.d b/src/rt/arraycast.d index d16d30d5fa..e16918dce5 100644 --- a/src/rt/arraycast.d +++ b/src/rt/arraycast.d @@ -25,7 +25,8 @@ void[] _d_arraycast(size_t tsize, size_t fsize, void[] a) auto length = a.length; auto nbytes = length * fsize; - if (nbytes % tsize != 0) + version (D_NoBoundsChecks) {} + else if (nbytes % tsize != 0) { throw new Error("array cast misalignment"); }