Commit c3b4e322

c3b4e3229e31Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 4 files · +2 added · ~2 modified

Description

Merge pull request #376 from mame/pr/sym-poly-hash-merge

codegen+runtime: add Hash#merge for sym_poly_hash

Details

Commit
c3b4e3229e31
Parent
b837214871fb
Merge parent
cddabab4d828

lib/sp_runtime.hmodifiedView file

@@ -1047,6 +1047,7 @@
10471047 static mrb_int sp_SymPolyHash_length(sp_SymPolyHash*h){return h->len;}
10481048 static sp_IntArray*sp_SymPolyHash_keys(sp_SymPolyHash*h){sp_IntArray*a=sp_IntArray_new();for(mrb_int i=0;i<h->len;i++)sp_IntArray_push(a,(mrb_int)h->order[i]);return a;}
10491049 static sp_PolyArray*sp_SymPolyHash_values(sp_SymPolyHash*h){sp_PolyArray*a=sp_PolyArray_new();for(mrb_int i=0;i<h->len;i++)sp_PolyArray_push(a,sp_SymPolyHash_get(h,h->order[i]));return a;}
1050+static sp_SymPolyHash*sp_SymPolyHash_merge(sp_SymPolyHash*a,sp_SymPolyHash*b){sp_SymPolyHash*r=sp_SymPolyHash_new();for(mrb_int i=0;i<a->len;i++)sp_SymPolyHash_set(r,a->order[i],sp_SymPolyHash_get(a,a->order[i]));for(mrb_int i=0;i<b->len;i++)sp_SymPolyHash_set(r,b->order[i],sp_SymPolyHash_get(b,b->order[i]));return r;}
10501051
10511052 /* PolyPolyHash: heterogeneous keys + values (both sp_RbVal). For
10521053 primitives the hash/eql is tag-based (value equality); for OBJ tag