This is an archive of the discontinued LLVM Phabricator instance.

[clang][NFC] Rearrange Comment Token and Lexer fields to reduce padding
ClosedPublic

Authored by njames93 on Oct 25 2020, 3:08 PM.

Details

Summary

Rearrange the fields to reduce the size of the classes

Diff Detail

Event Timeline

njames93 created this revision.Oct 25 2020, 3:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 25 2020, 3:08 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
njames93 requested review of this revision.Oct 25 2020, 3:08 PM
gribozavr2 added inline comments.Oct 26 2020, 12:07 AM
clang/include/clang/AST/CommentLexer.h
244

I'm not a fan of this change to Lexer because it breaks the grouping of fields: VerbatimBlockEndCommandName is no longer next to State.

There is only ever one Lexer class instance anyway, so any memory savings are not important I think.

njames93 updated this revision to Diff 300622.Oct 26 2020, 3:48 AM

Keep VerbatimBlockEndCommandName after LexerState while preserving smaller size

njames93 added inline comments.Oct 26 2020, 3:51 AM
clang/include/clang/AST/CommentLexer.h
244

Fair point, I've fixed that grouping of fields while keeping the smaller size, but if you think its still not worth it, I'll revert that change.
The token class size change would be worth it as they appear in vectors.

njames93 updated this revision to Diff 300623.Oct 26 2020, 3:54 AM

Fix field initialisation order in constructor

gribozavr2 accepted this revision.Oct 26 2020, 7:02 AM
gribozavr2 added inline comments.
clang/include/clang/AST/CommentLexer.h
70

Could you also swap Length and IntVal? It would be nice to keep Length and TextPtr next to each other.

This revision is now accepted and ready to land.Oct 26 2020, 7:02 AM