From 4d153ad951d71b6f2b6e6e6185011f8bffa458a2 Mon Sep 17 00:00:00 2001 From: Kouji Takao Date: Fri, 3 Apr 2026 00:13:01 +0900 Subject: [PATCH] fix: remove redundant obj variable in allocator functions Return TypedData_Make_Struct directly instead of assigning to a temporary variable in DisplayMode_s_allocate, Rect_s_allocate, and Point_s_allocate where obj is not used before return. Co-Authored-By: Claude Opus 4.6 (1M context) --- video.c.m4 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/video.c.m4 b/video.c.m4 index 50c44e9..908a630 100644 --- a/video.c.m4 +++ b/video.c.m4 @@ -125,8 +125,7 @@ static VALUE Display_new(int index) static VALUE DisplayMode_s_allocate(VALUE klass) { SDL_DisplayMode* mode; - VALUE obj = TypedData_Make_Struct(klass, SDL_DisplayMode, &SDL_DisplayMode_data_type, mode); - return obj; + return TypedData_Make_Struct(klass, SDL_DisplayMode, &SDL_DisplayMode_data_type, mode); } static VALUE DisplayMode_new(SDL_DisplayMode* mode) @@ -2491,8 +2490,7 @@ static VALUE Surface_s_new(int argc, VALUE* argv, VALUE self) static VALUE Rect_s_allocate(VALUE klass) { SDL_Rect* rect; - VALUE obj = TypedData_Make_Struct(klass, SDL_Rect, &SDL_Rect_data_type, rect); - return obj; + return TypedData_Make_Struct(klass, SDL_Rect, &SDL_Rect_data_type, rect); } /* @@ -2595,8 +2593,7 @@ static VALUE Rect_union(VALUE self, VALUE other) static VALUE Point_s_allocate(VALUE klass) { SDL_Point* point; - VALUE obj = TypedData_Make_Struct(klass, SDL_Point, &SDL_Point_data_type, point); - return obj; + return TypedData_Make_Struct(klass, SDL_Point, &SDL_Point_data_type, point); } /*