TFPGMap.TryGetData fails when Sorted=False
Original Reporter info from Mantis: dezlov
-
Reporter name: Denis Kozlov
Original Reporter info from Mantis: dezlov
- Reporter name: Denis Kozlov
Description:
TFPGMap.TryGetData uses binary search on unsorted keys by calling Find method blindly, which of course produces wrong results if keys are not sorted.
Patch is trivial. Use IndexOf instead of Find, which already uses either linear or binary search depending on the Sorted state.
Patch also makes TFPSMap.Find raise an exception if keys are not sorted, instead of silently producing wrong results - same fix was applied to TStringList.Find some time ago.
Additional information:
Patch and sample project are attached.
Mantis conversion info:
- Mantis ID: 31704
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 35942 (#e4184e05)
- Monitored by: » dezlov (Denis Kozlov)
- Target version: 3.2.0