Skip to content

Commit

Permalink
FIX: code refactoring
Browse files Browse the repository at this point in the history
Keeping just a `MT_Map` function for making a new `map` value. Years ago I introduced `Copy_Map`, because I was just learning the code structure.. now I'm a little bit more advanced and so know, that `MT_*` are common functions for _making datatype *_ and that the `type` argument of this function is used to specify, how to deal with values, when we want to `copy` the `map`.
  • Loading branch information
Oldes committed Feb 10, 2020
1 parent a84522c commit 5a4f0f0
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/core/t-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,9 @@
}
}


/***********************************************************************
**
*/ REBFLG Copy_Map(REBVAL *out, REBVAL *data, REBU64 types)
*/ REBFLG MT_Map(REBVAL *out, REBVAL *data, REBCNT type)
/*
***********************************************************************/
{
Expand All @@ -344,7 +343,7 @@
//COPY_BLK_PART(series, VAL_BLK_DATA(data), n);
Append_Map(series, data, UNKNOWN);

if (types != 0) Copy_Deep_Values(series, 0, SERIES_TAIL(series), types);
if (type != 0) Copy_Deep_Values(series, 0, SERIES_TAIL(series), type);

Rehash_Hash(series);

Expand All @@ -354,17 +353,6 @@
}


/***********************************************************************
**
*/ REBFLG MT_Map(REBVAL *out, REBVAL *data, REBCNT type)
/*
***********************************************************************/
{
//Oldes: MT means "make type" and has fixed arguments
return Copy_Map(out, data, 0);
}


/***********************************************************************
**
*/ REBSER *Map_To_Block(REBSER *mapser, REBINT what)
Expand Down Expand Up @@ -521,7 +509,7 @@
case A_TO:
// make map! [word val word val]
if (IS_BLOCK(arg) || IS_PAREN(arg) || IS_MAP(arg)) {
if (Copy_Map(D_RET, arg, 0)) return R_RET;
if (MT_Map(D_RET, arg, 0)) return R_RET;
Trap_Arg(arg);
// } else if (IS_NONE(arg)) {
// n = 3; // just a start
Expand All @@ -547,7 +535,7 @@
if (IS_DATATYPE(arg)) types |= TYPESET(VAL_DATATYPE(arg));
else types |= VAL_TYPESET(arg);
}
if (Copy_Map(D_RET, val, types)) return R_RET;
if (MT_Map(D_RET, val, types)) return R_RET;
Trap_Arg(val);
}
case A_CLEAR:
Expand Down

0 comments on commit 5a4f0f0

Please sign in to comment.