Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/opers.c: tweak and cleanup code; add tests #2296

Merged
merged 11 commits into from
Mar 27, 2018
Prev Previous commit
Next Next commit
kernel: perform FuncWITH_(HIDDEN)_IMPS_FLAGS checks earlier
In particular, before calling functions like FuncHASH_FLAGS which also
require flags as input.
  • Loading branch information
fingolfin committed Mar 27, 2018
commit 2ec9863b72fff0da3eab59d0dd8e2758a01faeea
30 changes: 16 additions & 14 deletions src/opers.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,14 @@ static Int WITH_HIDDEN_IMPS_HIT=0;
#endif
Obj FuncWITH_HIDDEN_IMPS_FLAGS(Obj self, Obj flags)
{
/* do some trivial checks - we have to do this so we can use
* UncheckedIS_SUBSET_FLAGS */
while ( TNUM_OBJ(flags) != T_FLAGS ) {
flags = ErrorReturnObj( "<flags> must be a flags list (not a %s)",
(Int)TNAM_OBJ(flags), 0L,
"you can replace <flags> via 'return <flags>;'" );
}

Int changed, i, lastand, stop;
Int hidden_imps_length = LEN_PLIST(HIDDEN_IMPS) / 2;
Int base_hash = INT_INTOBJ(FuncHASH_FLAGS(0, flags)) % HIDDEN_IMPS_CACHE_LENGTH;
Expand All @@ -854,13 +862,6 @@ Obj FuncWITH_HIDDEN_IMPS_FLAGS(Obj self, Obj flags)
Int old_moving;
Obj with = flags;

/* do some trivial checks - we have to do this so we can use
* UncheckedIS_SUBSET_FLAGS */
while ( TNUM_OBJ(flags) != T_FLAGS ) {
flags = ErrorReturnObj( "<flags> must be a flags list (not a %s)",
(Int)TNAM_OBJ(flags), 0L,
"you can replace <flags> via 'return <flags>;'" );
}
#ifdef HPCGAP
RegionWriteLock(REGION(WITH_HIDDEN_IMPS_FLAGS_CACHE));
#endif
Expand Down Expand Up @@ -972,6 +973,14 @@ static Int WITH_IMPS_FLAGS_HIT=0;
#endif
Obj FuncWITH_IMPS_FLAGS(Obj self, Obj flags)
{
/* do some trivial checks - we have to do this so we can use
* UncheckedIS_SUBSET_FLAGS */
while ( TNUM_OBJ(flags) != T_FLAGS ) {
flags = ErrorReturnObj( "<flags> must be a flags list (not a %s)",
(Int)TNAM_OBJ(flags), 0L,
"you can replace <flags> via 'return <flags>;'" );
}

Int changed, lastand, i, j, stop, imps_length;
Int base_hash = INT_INTOBJ(FuncHASH_FLAGS(0, flags)) % IMPS_CACHE_LENGTH;
Int hash = base_hash;
Expand All @@ -983,13 +992,6 @@ Obj FuncWITH_IMPS_FLAGS(Obj self, Obj flags)
Obj imp;
Obj trues;

/* do some trivial checks - we have to do this so we can use
* UncheckedIS_SUBSET_FLAGS */
while ( TNUM_OBJ(flags) != T_FLAGS ) {
flags = ErrorReturnObj( "<flags> must be a flags list (not a %s)",
(Int)TNAM_OBJ(flags), 0L,
"you can replace <flags> via 'return <flags>;'" );
}
#ifdef HPCGAP
RegionWriteLock(REGION(IMPLICATIONS_SIMPLE));
#endif
Expand Down