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

Ignore big fields on equality #239

Open
CodeDoctorDE opened this issue Oct 1, 2024 · 0 comments
Open

Ignore big fields on equality #239

CodeDoctorDE opened this issue Oct 1, 2024 · 0 comments

Comments

@CodeDoctorDE
Copy link

Hello,
I have currently this classes:

@MappableClass(generateMethods: GenerateMethods.all & ~GenerateMethods.equals)
class GameTable with GameTableMappable {
  final Map<VectorDefinition, TableCell> cells;
  final ItemLocation? background;

  const GameTable({
    this.cells = const {},
    this.background,
  });

  TableCell getCell(VectorDefinition position) =>
      cells[position] ?? TableCell();
}


@MappableClass()
final class WorldState with WorldStateMappable {
  final GameTable table;
  final String tableName;
  final GameInfo info;
  final String? name;
  final Channel id;
  final Map<String, Set<Channel>> teamMembers;
  final FileMetadata metadata;
  final QuokkaData data;
  final List<ChatMessage> messages;

  const WorldState({
    this.name,
    this.table = const GameTable(),
    this.tableName = '',
    this.info = const GameInfo(),
    this.metadata = const FileMetadata(),
    this.teamMembers = const {},
    this.messages = const [],
    this.id = kAuthorityChannel,
    required this.data,
  });
}

The problem now is: cells can be really, really big. The time calculating if cells are the same is very long. How can I only say that cells should be ignored when testing for equality?

The current functionality works when removing the equality operator. The problem now is if I use the class in world state. It also checks for the full map instead of only using the equality operator.
How can I fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant