@@ -7109,7 +7109,8 @@ get_constraints (MonoImage *image, int owner, MonoClass ***constraints, MonoGene
71097109{
71107110 MonoTableInfo * tdef = & image -> tables [MONO_TABLE_GENERICPARAMCONSTRAINT ];
71117111 guint32 cols [MONO_GENPARCONSTRAINT_SIZE ];
7112- guint32 i , token , found ;
7112+ locator_t loc ;
7113+ guint32 i , token , found , start ;
71137114 MonoClass * klass , * * res ;
71147115 GSList * cons = NULL , * tmp ;
71157116 MonoGenericContext * context = & container -> context ;
@@ -7120,7 +7121,26 @@ get_constraints (MonoImage *image, int owner, MonoClass ***constraints, MonoGene
71207121 found = 0 ;
71217122 /* FIXME: metadata-update */
71227123 guint32 rows = table_info_get_rows (tdef );
7123- for (i = 0 ; i < rows ; ++ i ) {
7124+
7125+ loc .idx = owner ;
7126+ loc .col_idx = MONO_GENPARCONSTRAINT_GENERICPAR ;
7127+ loc .t = tdef ;
7128+ loc .result = 0 ;
7129+
7130+ gboolean is_found = tdef -> base && mono_binary_search (& loc , tdef -> base , table_info_get_rows (tdef ), tdef -> row_size , table_locator ) != NULL ;
7131+ if (!is_found && !image -> has_updates )
7132+ return TRUE;
7133+
7134+ if (is_found ) {
7135+ /* Find the first entry by searching backwards */
7136+ while ((loc .result > 0 ) && (mono_metadata_decode_row_col (tdef , loc .result - 1 , MONO_GENPARCONSTRAINT_GENERICPAR ) == owner ))
7137+ loc .result -- ;
7138+ start = loc .result ;
7139+ } else {
7140+ start = 0 ;
7141+ }
7142+
7143+ for (i = start ; i < rows ; ++ i ) {
71247144 mono_metadata_decode_row (tdef , i , cols , MONO_GENPARCONSTRAINT_SIZE );
71257145 if (cols [MONO_GENPARCONSTRAINT_GENERICPAR ] == owner ) {
71267146 token = mono_metadata_token_from_dor (cols [MONO_GENPARCONSTRAINT_CONSTRAINT ]);
0 commit comments