Changeset 10146


Ignore:
Timestamp:
Feb 9, 2011, 11:06:52 AM (9 years ago)
Author:
rohlfs
Message:
replace the selection of the blockType from a string comparison to a switch - statement.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcorsika/MCorsikaFormat.cc

    r10060 r10146  
    114114                                    Int_t & blockLength) const
    115115{
    116     char blockHeader[5];
    117     blockHeader[4] = 0;
    118     fIn->read(blockHeader, 4);
     116    int blockHeader;
     117    fIn->read((char*)&blockHeader, 4);
    119118    if (fIn->eof())
    120119        return kFALSE;
     
    124123    blockLength     = 272 * 4;
    125124
    126     if (strcmp(blockHeader, "RUNH") == 0)
    127         blockType = 1200;
    128     else if (strcmp(blockHeader, "RUNE") == 0)
    129         blockType = 1210;
    130     else if (strcmp(blockHeader, "EVTH") == 0)
    131         blockType = 1202;
    132     else if (strcmp(blockHeader, "EVTE") == 0)
    133         blockType = 1209;
    134     else    // the events, they don't have a specific header
    135         {
    136         blockType = 1105;
    137         fIn->seekg(-4, ios::cur);
    138         blockLength += 4;
    139         }
    140 
     125
     126    switch(blockHeader)
     127      {
     128      case 1213093202 : // RUNH
     129         blockType = 1200;
     130         break;
     131      case 1162761554 : // RUNE
     132         blockType = 1210;
     133         break;
     134      case 1213486661 : // EVTH
     135         blockType = 1202;
     136         break;
     137      case 1163155013 : // EVTE
     138         blockType = 1209;
     139         break;
     140      default:          // the events, they don't have a specific header
     141         blockType = 1105;
     142         fIn->seekg(-4, ios::cur);
     143         blockLength += 4;
     144      }           
    141145    return kTRUE;
    142146}
Note: See TracChangeset for help on using the changeset viewer.