[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Patch] Optimize pkgAllUpgrade() in algorithms.cc



Hi,

Using valgrind I noticed that pkgAllUpgrade in apt-pkg/algorithms.cc was checking the APT::Ignore-Hold config variable way more than it needed to. (It won't ever change over the life of the function.)

By looking up the config value once before the for loop and caching the result, pkgAllUpgrade takes half as long to execute as it used to. In a real-world application, this reduced the startup time of an application that called pkgAllUpgrade as part of its startup by ~5%. (Around a 200ms gain)

I've attached the patch with the optimization to this email.

Cheers,
Jonathan

Attachment: readconfigonce.diff
Description: Binary data


Reply to: