Skip to content

Commit

Permalink
Remove unused NSI set operators
Browse files Browse the repository at this point in the history
  • Loading branch information
GrieferAtWork committed May 19, 2024
1 parent df1ca20 commit 37bced4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 105 deletions.
13 changes: 13 additions & 0 deletions include/deemon/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,19 @@ struct Dee_type_seq {
WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_bounditem_string_len_hash)(DeeObject *self, char const *key, size_t keylen, Dee_hash_t hash);
WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_hasitem_string_len_hash)(DeeObject *self, char const *key, size_t keylen, Dee_hash_t hash);

#if 0 /* TODO: Do this to allow DEX modules to extend `DeeKw_GetItemNR()' */
/* All of the following are *always* and *unconditionally* implemented
* when the associated type has the "tp_features & TF_KW" flag set,
* with the exception of `DeeKwds_Type', which has that flag, but does
* not implement these operators. */
WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_getitemnr)(DeeObject *__restrict self, /*string*/ DeeObject *__restrict name);
WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_getitemnr_string_hash)(DeeObject *__restrict self, char const *__restrict name, Dee_hash_t hash);
WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_getitemnr_string_len_hash)(DeeObject *__restrict self, char const *__restrict name, size_t namelen, Dee_hash_t hash);
WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_trygetitemnr)(DeeObject *__restrict self, /*string*/ DeeObject *name);
WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_trygetitemnr_string_hash)(DeeObject *__restrict self, char const *__restrict name, Dee_hash_t hash);
WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_trygetitemnr_string_len_hash)(DeeObject *__restrict self, char const *__restrict name, size_t namelen, Dee_hash_t hash);
#endif

/* [0..1][owned][lock(WRITE_ONCE)]
* Internal cache for how sequence functions are implemented for this type. */
struct Dee_type_seq_cache *_tp_seqcache;
Expand Down
25 changes: 0 additions & 25 deletions include/deemon/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,36 +451,11 @@ struct Dee_type_nsi {
* @return: 0: `key' didn't exist and was thus added (*p_oldvalue is left unchanged)
* @return: -1: Error. */
WUNUSED_T NONNULL_T((1, 2, 3)) int (DCALL *nsi_insertnew)(DeeObject *self, DeeObject *key, DeeObject *value, DREF DeeObject **p_oldvalue);

#if 0 /* TODO: Do this to allow DEX modules to extend `DeeKw_GetItemNR()' */
/* All of the following are *always* and *unconditionally* implemented
* when the associated type has the "tp_features & TF_KW" flag set,
* with the exception of `DeeKwds_Type', which has that flag, but does
* not implement these operators. */
WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *nsi_kw_getitemnr)(DeeObject *__restrict self, /*string*/ DeeObject *__restrict name);
WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *nsi_kw_getitemnr_string_hash)(DeeObject *__restrict self, char const *__restrict name, Dee_hash_t hash);
WUNUSED_T ATTR_INS_T(2, 3) NONNULL_T((1)) DeeObject *(DCALL *nsi_kw_getitemnr_string_len_hash)(DeeObject *__restrict self, char const *__restrict name, size_t namelen, Dee_hash_t hash);
WUNUSED_T NONNULL_T((1, 2, 3)) DeeObject *(DCALL *nsi_kw_getitemnr_def)(DeeObject *__restrict self, /*string*/ DeeObject *name, DeeObject *def);
WUNUSED_T NONNULL_T((1, 2, 4)) DeeObject *(DCALL *nsi_kw_getitemnr_string_hash_def)(DeeObject *__restrict self, char const *__restrict name, Dee_hash_t hash, DeeObject *def);
WUNUSED_T ATTR_INS_T(2, 3) NONNULL_T((1, 5)) DeeObject *(DCALL *nsi_kw_getitemnr_string_len_hash_def)(DeeObject *__restrict self, char const *__restrict name, size_t namelen, Dee_hash_t hash, DeeObject *def);
#endif
} nsi_maplike;

struct { /* TYPE_SEQX_CLASS_SET */
/* [1..1] ERROR: (size_t)-1 */
WUNUSED_T NONNULL_T((1)) size_t (DCALL *nsi_getsize)(DeeObject *__restrict self);

/* Insert a new `key' into the set
* @return: 1: The given `key' was inserted.
* @return: 0: A identical key was already apart of the set.
* @return: -1: Error. */
WUNUSED_T NONNULL_T((1, 2)) int (DCALL *nsi_insert)(DeeObject *self, DeeObject *key);

/* Remove a given `key' from the set
* @return: 1: The given `key' was removed.
* @return: 0: The given `key' could not be found within the set.
* @return: -1: Error. */
WUNUSED_T NONNULL_T((1, 2)) int (DCALL *nsi_remove)(DeeObject *self, DeeObject *key);
} nsi_setlike;
}
#ifndef __COMPILER_HAVE_TRANSPARENT_UNION
Expand Down
2 changes: 0 additions & 2 deletions src/deemon/objects/hashset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1853,8 +1853,6 @@ PRIVATE struct type_nsi tpconst hashset_nsi = {
{
/* .nsi_setlike = */ {
/* .nsi_getsize = */ (dfunptr_t)&hashset_size,
/* .nsi_insert = */ (dfunptr_t)&DeeHashSet_Insert,
/* .nsi_remove = */ (dfunptr_t)&DeeHashSet_Remove,
}
}
};
Expand Down
76 changes: 0 additions & 76 deletions src/dex/collections/bitset.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,35 +337,6 @@ bs_size(Bitset *__restrict self) {
return bitset_popcount(self->bs_bitset, self->bs_nbits);
}

PRIVATE WUNUSED NONNULL((1)) int DCALL
bs_nsi_insert(Bitset *self, DeeObject *key) {
size_t bitno;
if (DeeObject_AsSize(key, &bitno))
goto err;
if unlikely(bitno >= self->bs_nbits)
goto err_too_large;
return bitset_atomic_fetchset(self->bs_bitset, bitno) ? 0 : 1;
err_too_large:
return bs_err_bad_index(self, bitno);
err:
return -1;
}

PRIVATE WUNUSED NONNULL((1)) int DCALL
bs_nsi_remove(Bitset *self, DeeObject *key) {
size_t bitno;
if (DeeObject_AsSize(key, &bitno))
goto err;
if unlikely(bitno >= self->bs_nbits)
goto err_too_large;
return bitset_atomic_fetchclear(self->bs_bitset, bitno) ? 1 : 0;
err_too_large:
return bs_err_bad_index(self, bitno);
err:
return -1;
}


PRIVATE WUNUSED NONNULL((1)) dhash_t DCALL
bs_hash(Bitset *__restrict self) {
size_t bitno;
Expand Down Expand Up @@ -1580,8 +1551,6 @@ PRIVATE struct type_nsi tpconst bs_nsi = {
{
/* .nsi_setlike = */ {
/* .nsi_getsize = */ (dfunptr_t)&bs_size,
/* .nsi_insert = */ (dfunptr_t)&bs_nsi_insert,
/* .nsi_remove = */ (dfunptr_t)&bs_nsi_remove,
}
}
};
Expand Down Expand Up @@ -2574,49 +2543,6 @@ bsv_size(BitsetView *__restrict self) {
self->bsv_endbit);
}

PRIVATE WUNUSED NONNULL((1)) int DCALL
bsv_nsi_insert(BitsetView *self, DeeObject *key) {
size_t bitno;
if (DeeObject_AsSize(key, &bitno))
goto err;
if unlikely(bitno >= BitsetView_GetNBits(self))
goto err_too_large;
if unlikely(!BitsetView_IsWritable(self))
goto err_readonly;
return bitset_atomic_fetchset(BitsetView_GetBitset(self),
self->bsv_startbit + bitno)
? 0
: 1;
err_readonly:
return bsv_err_readonly(self);
err_too_large:
return bsv_err_bad_index(self, bitno);
err:
return -1;
}

PRIVATE WUNUSED NONNULL((1)) int DCALL
bsv_nsi_remove(BitsetView *self, DeeObject *key) {
size_t bitno;
if (DeeObject_AsSize(key, &bitno))
goto err;
if unlikely(bitno >= BitsetView_GetNBits(self))
goto err_too_large;
if unlikely(!BitsetView_IsWritable(self))
goto err_readonly;
return bitset_atomic_fetchclear(BitsetView_GetBitset(self),
self->bsv_startbit + bitno)
? 1
: 0;
err_readonly:
return bsv_err_readonly(self);
err_too_large:
return bsv_err_bad_index(self, bitno);
err:
return -1;
}


PRIVATE WUNUSED NONNULL((1)) dhash_t DCALL
bsv_hash(BitsetView *__restrict self) {
size_t bitno;
Expand Down Expand Up @@ -3913,8 +3839,6 @@ PRIVATE struct type_nsi tpconst bsv_nsi = {
{
/* .nsi_setlike = */ {
/* .nsi_getsize = */ (dfunptr_t)&bsv_size,
/* .nsi_insert = */ (dfunptr_t)&bsv_nsi_insert,
/* .nsi_remove = */ (dfunptr_t)&bsv_nsi_remove,
}
}
};
Expand Down
2 changes: 0 additions & 2 deletions src/dex/collections/uset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,8 +1230,6 @@ PRIVATE struct type_nsi tpconst uset_nsi = {
{
/* .nsi_setlike = */ {
/* .nsi_getsize = */ (dfunptr_t)&uset_size,
/* .nsi_insert = */ (dfunptr_t)&USet_Insert,
/* .nsi_remove = */ (dfunptr_t)&USet_Remove,
}
}
};
Expand Down

0 comments on commit 37bced4

Please sign in to comment.