Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:11:56

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // Author: seongkim@google.com (Seong Beom Kim)
0009 //  Based on original Protocol Buffers design by
0010 //  Sanjay Ghemawat, Jeff Dean, and others.
0011 
0012 #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__
0014 
0015 #include "google/protobuf/compiler/cpp/message_layout_helper.h"
0016 
0017 namespace google {
0018 namespace protobuf {
0019 namespace compiler {
0020 namespace cpp {
0021 
0022 // Rearranges the fields of a message to minimize padding.
0023 // Fields are grouped by the type and the size.
0024 // For example, grouping four boolean fields and one int32
0025 // field results in zero padding overhead. See OptimizeLayout's
0026 // comment for details.
0027 class PaddingOptimizer : public MessageLayoutHelper {
0028  public:
0029   PaddingOptimizer() {}
0030   ~PaddingOptimizer() override {}
0031 
0032   void OptimizeLayout(std::vector<const FieldDescriptor*>* fields,
0033                       const Options& options,
0034                       MessageSCCAnalyzer* scc_analyzer) override;
0035 };
0036 
0037 }  // namespace cpp
0038 }  // namespace compiler
0039 }  // namespace protobuf
0040 }  // namespace google
0041 
0042 #endif  // GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__