refactor(handlers): replace temporary variable pointer pattern with new() builtin
Simplify pointer creation across kobo, koreader, and queue handlers by replacing the two-step pattern (assign to local, then take address) with inline new() calls. This reduces verbosity without changing behavior: Before: remaining := int(a - b) pagesRemaining = &remaining After: pagesRemaining = new(int(a - b)) Covers page calculations, chapter/progress fields, UUID formatting, and timestamp string conversions.
This commit is contained in:
@@ -310,8 +310,7 @@ func uuidPtrToString(u pgtype.UUID) *string {
|
||||
if !u.Valid {
|
||||
return nil
|
||||
}
|
||||
s := uuid.UUID(u.Bytes).String()
|
||||
return &s
|
||||
return new(uuid.UUID(u.Bytes).String())
|
||||
}
|
||||
|
||||
func textPtrToString(t pgtype.Text) *string {
|
||||
@@ -325,6 +324,5 @@ func timestamptzPtrToString(t pgtype.Timestamptz) *string {
|
||||
if !t.Valid {
|
||||
return nil
|
||||
}
|
||||
s := t.Time.Format("2006-01-02T15:04:05Z07:00")
|
||||
return &s
|
||||
return new(t.Time.Format("2006-01-02T15:04:05Z07:00"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user