@@ -410,11 +410,11 @@ def _parse_metadata(self) -> None:
410
410
411
411
def _process_page_meta (self ) -> bool :
412
412
self ._read_page_header ()
413
- pt = [ const .page_meta_type , const .page_amd_type ] + const .page_mix_types
413
+ pt = const .page_meta_types + [ const .page_amd_type , const .page_mix_type ]
414
414
if self ._current_page_type in pt :
415
415
self ._process_page_metadata ()
416
- is_data_page = self ._current_page_type & const .page_data_type
417
- is_mix_page = self ._current_page_type in const .page_mix_types
416
+ is_data_page = self ._current_page_type == const .page_data_type
417
+ is_mix_page = self ._current_page_type == const .page_mix_type
418
418
return bool (
419
419
is_data_page
420
420
or is_mix_page
@@ -424,7 +424,9 @@ def _process_page_meta(self) -> bool:
424
424
def _read_page_header (self ):
425
425
bit_offset = self ._page_bit_offset
426
426
tx = const .page_type_offset + bit_offset
427
- self ._current_page_type = self ._read_int (tx , const .page_type_length )
427
+ self ._current_page_type = (
428
+ self ._read_int (tx , const .page_type_length ) & const .page_type_mask2
429
+ )
428
430
tx = const .block_count_offset + bit_offset
429
431
self ._current_page_block_count = self ._read_int (tx , const .block_count_length )
430
432
tx = const .subheader_count_offset + bit_offset
@@ -774,13 +776,13 @@ def _read_next_page(self):
774
776
raise ValueError (msg )
775
777
776
778
self ._read_page_header ()
777
- page_type = self ._current_page_type
778
- if page_type == const .page_meta_type :
779
+ if self ._current_page_type in const .page_meta_types :
779
780
self ._process_page_metadata ()
780
781
781
- is_data_page = page_type & const .page_data_type
782
- pt = [const .page_meta_type ] + const .page_mix_types
783
- if not is_data_page and self ._current_page_type not in pt :
782
+ if self ._current_page_type not in const .page_meta_types + [
783
+ const .page_data_type ,
784
+ const .page_mix_type ,
785
+ ]:
784
786
return self ._read_next_page ()
785
787
786
788
return False
0 commit comments