authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2020-08-15 21:14:56+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-16 22:35:28-07:00
log37ae2464053628d10c7e7e7165ba8a267006b0ad
tree3a7499eb68406f6726833c57031bf5f3035ff989
parentab6ffa8a3c1e3fa802cacd970d3ed415ba25a85e

Inline Fe.{sub,mul,sq} for a performance boost in release-safe mode


1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/crypto/25519/field.zig+3-3
......@@ -114,7 +114,7 @@ pub const Fe = struct {
114114 return fe;
115115 }
116116
117 pub fn sub(a: Fe, b: Fe) Fe {
117 pub inline fn sub(a: Fe, b: Fe) Fe {
118118 var fe = b;
119119 comptime var i = 0;
120120 inline while (i < 4) : (i += 1) {
......@@ -200,7 +200,7 @@ pub const Fe = struct {
200200 return .{ .limbs = rs };
201201 }
202202
203 pub fn mul(a: Fe, b: Fe) Fe {
203 pub inline fn mul(a: Fe, b: Fe) Fe {
204204 var ax: [5]u128 = undefined;
205205 var bx: [5]u128 = undefined;
206206 var a19: [5]u128 = undefined;
......@@ -223,7 +223,7 @@ pub const Fe = struct {
223223 return _carry128(&r);
224224 }
225225
226 fn _sq(a: Fe, double: comptime bool) Fe {
226 inline fn _sq(a: Fe, double: comptime bool) Fe {
227227 var ax: [5]u128 = undefined;
228228 var r: [5]u128 = undefined;
229229 comptime var i = 0;