Skip to content

Commit

Permalink
feat: small performance tweaks for Message
Browse files Browse the repository at this point in the history
It is the widget most often built, so every small bit helps.
- replace a List with an array (should be easier to optimize for the
  compiler)
- remove a Padding widget and use the parent Container's padding instead
  • Loading branch information
gilice committed Jul 28, 2023
1 parent 6172818 commit 20ccf65
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/pages/chat/events/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ class Message extends StatelessWidget {
nextEvent == null ||
!event.originServerTs.sameEnvironment(nextEvent!.originServerTs);
final sameSender = nextEvent != null &&
[
{
EventTypes.Message,
EventTypes.Sticker,
EventTypes.Encrypted,
].contains(nextEvent!.type) &&
}.contains(nextEvent!.type) &&
nextEvent?.relationshipType == null &&
nextEvent!.senderId == event.senderId &&
!displayTime;
Expand Down Expand Up @@ -407,13 +407,11 @@ class Message extends StatelessWidget {
: Theme.of(context).primaryColor.withAlpha(0),
constraints:
const BoxConstraints(maxWidth: FluffyThemes.columnWidth * 2.5),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 4.0 * AppConfig.bubbleSizeFactor,
),
child: container,
padding: EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 4.0 * AppConfig.bubbleSizeFactor,
),
child: container,
),
),
);
Expand Down

0 comments on commit 20ccf65

Please sign in to comment.