feat: Simplify OurDB.set function
- Remove unnecessary nested `if` statement in `OurDB.set`. - Improve code readability and maintainability.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user