Remove struct CFX_CTTGSUBTable::TLangSysRecord

Since only 1 field in this struct is actually used, replace the struct
with just the field. Change ParseLangSys(), which handles the field, to
return the data instead of using an out-parameter.

Change-Id: Id20631b376ce7e724962355938ab43bda9006684
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107431
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.cpp b/core/fpdfapi/font/cfx_cttgsubtable.cpp
index ae5a841..7726371 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.cpp
+++ b/core/fpdfapi/font/cfx_cttgsubtable.cpp
@@ -33,7 +33,7 @@
 
   for (const TScriptRecord& script : ScriptList) {
     for (const auto& record : script.LangSysRecords) {
-      for (uint16_t index : record.FeatureIndices) {
+      for (uint16_t index : record) {
         if (IsVerticalFeatureTag(FeatureList[index].FeatureTag))
           m_featureSet.insert(index);
       }
@@ -194,20 +194,22 @@
 void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, TScriptRecord* rec) {
   FT_Bytes sp = raw;
   rec->DefaultLangSys = GetUInt16(sp);
-  rec->LangSysRecords = std::vector<TLangSysRecord>(GetUInt16(sp));
-  for (auto& sysRecord : rec->LangSysRecords) {
-    sysRecord.LangSysTag = GetUInt32(sp);
-    ParseLangSys(&raw[GetUInt16(sp)], &sysRecord);
+  rec->LangSysRecords = std::vector<FeatureIndices>(GetUInt16(sp));
+  for (auto& sys_record : rec->LangSysRecords) {
+    // Skip over "LangSysTag" field.
+    sp += 4;
+    sys_record = ParseLangSys(&raw[GetUInt16(sp)]);
   }
 }
 
-void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, TLangSysRecord* rec) {
-  FT_Bytes sp = raw;
-  rec->LookupOrder = GetUInt16(sp);
-  rec->ReqFeatureIndex = GetUInt16(sp);
-  rec->FeatureIndices = DataVector<uint16_t>(GetUInt16(sp));
-  for (auto& element : rec->FeatureIndices)
+CFX_CTTGSUBTable::FeatureIndices CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw) {
+  // Skip over "LookupOrder" and "ReqFeatureIndex" fields.
+  FT_Bytes sp = raw + 4;
+  FeatureIndices result(GetUInt16(sp));
+  for (auto& element : result) {
     element = GetUInt16(sp);
+  }
+  return result;
 }
 
 void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw) {
@@ -315,10 +317,6 @@
   return rec;
 }
 
-CFX_CTTGSUBTable::TLangSysRecord::TLangSysRecord() = default;
-
-CFX_CTTGSUBTable::TLangSysRecord::~TLangSysRecord() = default;
-
 CFX_CTTGSUBTable::TScriptRecord::TScriptRecord() = default;
 
 CFX_CTTGSUBTable::TScriptRecord::~TScriptRecord() = default;
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.h b/core/fpdfapi/font/cfx_cttgsubtable.h
index 0555333..6405c24 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.h
+++ b/core/fpdfapi/font/cfx_cttgsubtable.h
@@ -25,15 +25,7 @@
   uint32_t GetVerticalGlyph(uint32_t glyphnum) const;
 
  private:
-  struct TLangSysRecord {
-    TLangSysRecord();
-    ~TLangSysRecord();
-
-    uint32_t LangSysTag = 0;
-    uint16_t LookupOrder = 0;
-    uint16_t ReqFeatureIndex = 0;
-    DataVector<uint16_t> FeatureIndices;
-  };
+  using FeatureIndices = DataVector<uint16_t>;
 
   struct TScriptRecord {
     TScriptRecord();
@@ -41,7 +33,7 @@
 
     uint32_t ScriptTag = 0;
     uint16_t DefaultLangSys = 0;
-    std::vector<TLangSysRecord> LangSysRecords;
+    std::vector<FeatureIndices> LangSysRecords;
   };
 
   struct TFeatureRecord {
@@ -125,7 +117,7 @@
   bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist);
   void ParseScriptList(FT_Bytes raw);
   void ParseScript(FT_Bytes raw, TScriptRecord* rec);
-  void ParseLangSys(FT_Bytes raw, TLangSysRecord* rec);
+  FeatureIndices ParseLangSys(FT_Bytes raw);
   void ParseFeatureList(FT_Bytes raw);
   void ParseFeature(FT_Bytes raw, TFeatureRecord* rec);
   void ParseLookupList(FT_Bytes raw);