Convert a few tvFoo functions to take parameters by reference

Since TypedValue::operator= is dangerous, something like
tvTeleport is usually what you want to use, but it doesn't work with
temporary TypedValues (e.g. return values of things like make_tv or
cellAdd), because it took the arguments by pointer.  This also means
we can change it to take parameters by value later without updating
callsites.  This diff does the tvDup family and changes tvTeleport to
tvCopy.  I'll gradually get the other ones done, but I just need these
for now to work with temporaries for changing SetOp to not use Variant
arithmetic.
Esse commit está contido em:
Jordan DeLong
2013-06-28 13:41:13 -07:00
commit de Sara Golemon
commit 8220a18060
18 arquivos alterados com 166 adições e 139 exclusões
+6 -6
Ver Arquivo
@@ -818,14 +818,14 @@ HOT_FUNC static
void iterValue(ArrayIter* iter, TypedValue* out) {
Variant val = iter->iterValue<Coll>(Style());
assert(val.getRawType() != KindOfRef);
tvDupCell(val.asTypedValue(), out);
cellDup(*val.asTypedValue(), *out);
}
template<class Coll, class Style>
HOT_FUNC static
void iterKey(ArrayIter* iter, TypedValue* out) {
Variant key = iter->iterKey<Coll>(Style());
tvDupCell(key.asTypedValue(), out);
cellDup(*key.asTypedValue(), *out);
}
template<class Coll, class Style>
@@ -909,11 +909,11 @@ static inline void iter_value_cell_local_impl(Iter* iter, TypedValue* out) {
cur = cur->m_data.pref->tv();
}
}
tvDup(cur, out);
tvDup(*cur, *out);
} else {
Variant val = arrIter.second();
assert(val.getRawType() != KindOfRef);
tvDupCell(val.asTypedValue(), out);
cellDup(*val.asTypedValue(), *out);
}
tvRefcountedDecRefHelper(oldType, oldDatum);
}
@@ -931,7 +931,7 @@ static inline void iter_key_cell_local_impl(Iter* iter, TypedValue* out) {
arr.nvFirst(out);
} else {
Variant key = arr.first();
tvDupCell(key.asTypedValue(), out);
cellDup(*key.asTypedValue(), *out);
}
tvRefcountedDecRefHelper(oldType, oldDatum);
}
@@ -978,7 +978,7 @@ void getHphpArrayElm(HphpArray::Elm* elm, TypedValue* valOut,
}
} else {
TypedValue* cur = tvToCell(&elm->data);
tvDupCell(cur, valOut);
cellDup(*cur, *valOut);
if (keyOut) {
HphpArray::getElmKey(elm, keyOut);
}