hydrobyte / McJSON

A Delphi / Lazarus / C++Builder simple and small class for fast JSON parsing.
MIT License
58 stars 20 forks source link

Reminder: Different operations can lead to significant differences in efficiency! #26

Closed mchestnut163 closed 3 weeks ago

mchestnut163 commented 3 weeks ago

1.Obj.S['foo'] := 'bar'; 2.Obj.add('foo').asstring= 'bar'; The efficiency difference between the above two operation methods is huge

hydrobyte commented 3 weeks ago

Hi,

It is like this by design.

In conclusion, if you are sure your data do not have key duplication, use Add(). If you are not so sure, you can use a combination of HasKey() and Add() or use S[] shortners.

Thanks for the reminder.

hydrobyte commented 3 weeks ago

Done.