Skip to content

Commit

Permalink
refactor: deprecate default fn from Relocatable (keep-starknet-strang…
Browse files Browse the repository at this point in the history
…e#58)

We make use of Zig's default struct initialization to get rid of
the default() fn.
  • Loading branch information
eightfilms authored Oct 27, 2023
1 parent 95d7d5f commit 74cc575
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
14 changes: 2 additions & 12 deletions src/vm/memory/relocatable.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,9 @@ const CairoVMError = @import("../error.zig").CairoVMError;
// represented by a field element.
pub const Relocatable = struct {
// The index of the memory segment.
segment_index: u64,
segment_index: u64 = 0,
// The offset in the memory segment.
offset: u64,

// Creates a new Relocatable with the default values.
// # Returns
// A new Relocatable with the default values.
pub fn default() Relocatable {
return .{
.segment_index = 0,
.offset = 0,
};
}
offset: u64 = 0,

// Creates a new Relocatable.
// # Arguments
Expand Down
6 changes: 3 additions & 3 deletions src/vm/run_context.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ pub const RunContext = struct {
.ap = try allocator.create(Relocatable),
.fp = try allocator.create(Relocatable),
};
run_context.pc.* = Relocatable.default();
run_context.ap.* = Relocatable.default();
run_context.fp.* = Relocatable.default();
run_context.pc.* = .{};
run_context.ap.* = .{};
run_context.fp.* = .{};
return run_context;
}

Expand Down

0 comments on commit 74cc575

Please sign in to comment.