Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: pkg/analyzer/lib/src/summary/flat_buffers.dart

Issue 1792523002: Use specialized _FbUint8List and Uint8ListReader. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/flat_buffers_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.summary.flat_buffers; 5 library analyzer.src.summary.flat_buffers;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:math'; 9 import 'dart:math';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 const Uint32Reader() : super(); 713 const Uint32Reader() : super();
714 714
715 @override 715 @override
716 int get size => 4; 716 int get size => 4;
717 717
718 @override 718 @override
719 int read(BufferPointer bp) => bp._getUint32(); 719 int read(BufferPointer bp) => bp._getUint32();
720 } 720 }
721 721
722 /** 722 /**
723 * Reader of lists of unsigned 8-bit integer values.
724 *
725 * The returned unmodifiable lists lazily read values on access.
726 */
727 class Uint8ListReader extends Reader<List<int>> {
728 const Uint8ListReader();
729
730 @override
731 int get size => 4;
732
733 @override
734 List<int> read(BufferPointer bp) => new _FbUint8List(bp.derefObject());
735 }
736
737 /**
723 * The reader of unsigned 8-bit integers. 738 * The reader of unsigned 8-bit integers.
724 */ 739 */
725 class Uint8Reader extends Reader<int> { 740 class Uint8Reader extends Reader<int> {
726 const Uint8Reader() : super(); 741 const Uint8Reader() : super();
727 742
728 @override 743 @override
729 int get size => 1; 744 int get size => 1;
730 745
731 @override 746 @override
732 int read(BufferPointer bp) => bp._getUint8(); 747 int read(BufferPointer bp) => bp._getUint8();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 class _FbUint32List extends _FbList<int> { 848 class _FbUint32List extends _FbList<int> {
834 _FbUint32List(BufferPointer bp) : super(bp); 849 _FbUint32List(BufferPointer bp) : super(bp);
835 850
836 @override 851 @override
837 int operator [](int i) { 852 int operator [](int i) {
838 return bp._getUint32(4 + 4 * i); 853 return bp._getUint32(4 + 4 * i);
839 } 854 }
840 } 855 }
841 856
842 /** 857 /**
858 * List backed by 8-bit unsigned integers.
859 */
860 class _FbUint8List extends _FbList<int> {
861 _FbUint8List(BufferPointer bp) : super(bp);
862
863 @override
864 int operator [](int i) {
865 return bp._getUint8(4 + i);
866 }
867 }
868
869 /**
843 * Class that describes the structure of a table. 870 * Class that describes the structure of a table.
844 */ 871 */
845 class _VTable { 872 class _VTable {
846 final List<int> fieldTails = <int>[]; 873 final List<int> fieldTails = <int>[];
847 final List<int> fieldOffsets = <int>[]; 874 final List<int> fieldOffsets = <int>[];
848 875
849 /** 876 /**
850 * The size of the table that uses this VTable. 877 * The size of the table that uses this VTable.
851 */ 878 */
852 int tableSize; 879 int tableSize;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 // Table size. 933 // Table size.
907 buf.setUint16(bufOffset, tableSize, Endianness.LITTLE_ENDIAN); 934 buf.setUint16(bufOffset, tableSize, Endianness.LITTLE_ENDIAN);
908 bufOffset += 2; 935 bufOffset += 2;
909 // Field offsets. 936 // Field offsets.
910 for (int fieldOffset in fieldOffsets) { 937 for (int fieldOffset in fieldOffsets) {
911 buf.setUint16(bufOffset, fieldOffset, Endianness.LITTLE_ENDIAN); 938 buf.setUint16(bufOffset, fieldOffset, Endianness.LITTLE_ENDIAN);
912 bufOffset += 2; 939 bufOffset += 2;
913 } 940 }
914 } 941 }
915 } 942 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/flat_buffers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698