From f47703f599cab2b9c7421841dc1558d1a91c8bdb Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Wed, 19 Feb 2025 01:18:23 +0200 Subject: [PATCH] feat: Simplify `OurDB.set` function - Remove unnecessary nested `if` statement in `OurDB.set`. - Improve code readability and maintainability. --- lib/data/ourdb/db.v | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/data/ourdb/db.v b/lib/data/ourdb/db.v index a9f6e40c..121d4a74 100644 --- a/lib/data/ourdb/db.v +++ b/lib/data/ourdb/db.v @@ -29,16 +29,14 @@ pub fn (mut db OurDB) set(args OurDBSetArgs) !u32 { // if id points to an empty location, return an error // else, overwrite data if id := args.id { - if id != 0 { - // this is an update - location := db.lookup.get(id)! - if location.position == 0 { - return error('cannot set id for insertions when incremental mode is enabled') - } - - db.set_(id, location, args.data)! - return id + // this is an update + location := db.lookup.get(id)! + if location.position == 0 { + return error('cannot set id for insertions when incremental mode is enabled') } + + db.set_(id, location, args.data)! + return id } // this is an insert