Skip to content
Permalink
Browse files

Remove unused fields from ArrayIter

Summary:
Shrink ArrayIter to 24 bytes by removing unused fields.

The Iter slot still remains at 32 bytes due to alignment. Kill the union in it
and delete its ctor/dtor to make it obvious that it's not constructible.

Reviewed By: ricklavoie

Differential Revision: D13740721

fbshipit-source-id: 0c924ec97f150097969bb6e2b953e917123bad8f
  • Loading branch information...
jano authored and hhvm-bot committed Jan 22, 2019
1 parent 12a645b commit b9ab7e60d86d0ab60125152b74ca49dadcfb4bc0
Showing with 6 additions and 16 deletions.
  1. +6 −16 hphp/runtime/base/array-iterator.h
@@ -299,14 +299,8 @@ struct ArrayIter {
const ArrayData* m_data;
ObjectData* m_obj;
};
public:
// m_pos is used by the array implementation to track the current position
// in the array. Beware that when m_data is null, m_pos is uninitialized.
// Current position. Beware that when m_data is null, m_pos is uninitialized.
ssize_t m_pos;
private:
// to be removed in the next diff
MaybeCountable* m_unused;
UNUSED int m_alsoUnused;
// This is unioned so new_iter_array can initialize it more
// efficiently.
union {
@@ -316,26 +310,22 @@ struct ArrayIter {
};
uint32_t m_itypeAndNextHelperIdx;
};

friend struct Iter;
};

///////////////////////////////////////////////////////////////////////////////

struct alignas(16) Iter {
const ArrayIter& arr() const { return m_u.aiter; }
ArrayIter& arr() { return m_u.aiter; }

Iter() = delete;
~Iter() = delete;
const ArrayIter& arr() const { return m_iter; }
ArrayIter& arr() { return m_iter; }
template <bool Local> bool init(TypedValue* c1);
bool next();
bool nextLocal(const ArrayData*);
void free();

private:
union Data {
Data() {}
ArrayIter aiter;
} m_u;
ArrayIter m_iter;
};

//////////////////////////////////////////////////////////////////////

0 comments on commit b9ab7e6

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.