Index: lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c
===================================================================
--- lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c	(revision 4758)
+++ lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c	(revision 4759)
@@ -176,4 +176,19 @@
 			dyn_features[fnum] = features[i];
 			fnum++;
+		}
+	}
+
+	/* Renumber the features linearly, so that feature number N is at
+	   position N in the array. This allows for O(1) look-ups. */
+	for (i = 0; i < fnum; i++) {
+		int j, old;
+
+		old = dyn_features[i].data.number;
+		dyn_features[i].data.number = i;
+		for (j = i + 1;
+		     j < fnum && dyn_features[j].data.mapping != SENSORS_NO_MAPPING;
+		     j++) {
+			if (dyn_features[j].data.mapping == old)
+				dyn_features[j].data.mapping = i;
 		}
 	}
