MRI-Binding: Reduce number of object allocations
Previously, wrapped instances of mkxp core classes were stored as RData ivars inside the actual object. This turned out to be pointless as RData objects themselves are perfectly valid objects that can carry ivars and have parent classes. Therefore, the RData objects are now exposed directly to the user scripts, effectively halving the amount of object allocations.
This commit is contained in:
parent
8dd6b63fc4
commit
f067e0eff8
11 changed files with 37 additions and 25 deletions
|
@ -28,7 +28,7 @@
|
|||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
|
||||
static rb_data_type_struct TilemapAutotilesType;
|
||||
rb_data_type_struct TilemapAutotilesType;
|
||||
|
||||
RB_METHOD(tilemapAutotilesSet)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ RB_METHOD(tilemapInitialize)
|
|||
/* Construct object */
|
||||
t = new Tilemap(viewport);
|
||||
|
||||
setPrivateData(self, t, TilemapType);
|
||||
setPrivateData(self, t);
|
||||
|
||||
rb_iv_set(self, "viewport", viewportObj);
|
||||
|
||||
|
@ -144,6 +144,7 @@ tilemapBindingInit()
|
|||
initType(TilemapAutotilesType, "TilemapAutotiles", 0);
|
||||
|
||||
VALUE klass = rb_define_class("TilemapAutotiles", rb_cObject);
|
||||
rb_define_alloc_func(klass, classAllocate<&TilemapAutotilesType>);
|
||||
|
||||
_rb_define_method(klass, "[]=", tilemapAutotilesSet);
|
||||
_rb_define_method(klass, "[]", tilemapAutotilesGet);
|
||||
|
@ -151,6 +152,7 @@ tilemapBindingInit()
|
|||
INIT_TYPE(Tilemap);
|
||||
|
||||
klass = rb_define_class("Tilemap", rb_cObject);
|
||||
rb_define_alloc_func(klass, classAllocate<&TilemapType>);
|
||||
|
||||
disposableBindingInit<Tilemap>(klass);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue