Show
Ignore:
Timestamp:
09/21/07 14:15:18 (7 years ago)
Author:
khali
Message:

Scan chip features only once at initialization time, rather than on
each update. The chip list and chip features do not change until
sensors_cleanup() is called, so there's no point in doing the
same work over and over again.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sense.c

    r4825 r4828  
    169169    ret = setChip (chip); 
    170170  } else { 
    171     ChipDescriptor *descriptor; 
    172     descriptor = generateChipDescriptor (chip); 
    173     if (descriptor) { 
    174       ret = doKnownChip (chip, descriptor, action); 
    175       free (descriptor->features); 
    176       free (descriptor); 
    177     } 
     171    int index0, chipindex = -1; 
     172    for (index0 = 0; knownChips[index0].features; ++ index0) 
     173      /* Trick: we compare addresses here. We know it works because both 
     174         pointers were returned by sensors_get_detected_chips(), so they 
     175         refer to libsensors internal structures, which do not move. */ 
     176      if (knownChips[index0].name == chip) { 
     177        chipindex = index0; 
     178        break; 
     179      } 
     180    if (chipindex >= 0) 
     181      ret = doKnownChip (chip, &knownChips[chipindex], action); 
    178182  } 
    179183  return ret;