... instead of GetIterator(). This allows us to avoid loading the cache entirely in SetTo(), and allows consumers to read the cache much more efficiently than loading it all into memory and then freeing it again afterwards. This technically breaks API/ABI, however the Package Kit APIs are not considered stable (I don't think.) All consumers adjusted. As we build the host tools with modern GCC only, I made update_package_requires use a C++11 lambda function. All others use out-of-line static methods. "time pkgman list-repos -v" (which has to read the whole cache) is ~0.5s before this change, and ~0.25s after this change, on my test VM. Change-Id: I6976b4cf5eb846fc925ed199dc00eb227fc81344 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10247 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]> Reviewed-by: Andrew Lindesay <[email protected]>
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
/*
|
|
* Copyright 2011, Haiku, Inc.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _PACKAGE__REPOSITORY_CACHE_H_
|
|
#define _PACKAGE__REPOSITORY_CACHE_H_
|
|
|
|
|
|
#include <Entry.h>
|
|
#include <String.h>
|
|
|
|
#include <package/PackageInfoSet.h>
|
|
#include <package/RepositoryInfo.h>
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
|
|
class BRepositoryCache {
|
|
public:
|
|
typedef bool (*GetPackageInfosCallback)(void* /* context */, const BPackageInfo& info);
|
|
|
|
public:
|
|
BRepositoryCache();
|
|
virtual ~BRepositoryCache();
|
|
|
|
status_t SetTo(const BEntry& entry);
|
|
|
|
const BRepositoryInfo& Info() const;
|
|
const BEntry& Entry() const;
|
|
bool IsUserSpecific() const;
|
|
|
|
status_t GetPackageInfos(GetPackageInfosCallback callback, void* context) const;
|
|
|
|
private:
|
|
struct RepositoryContentHandler;
|
|
|
|
status_t _ReadCache(const BPath& repositoryCachePath,
|
|
BRepositoryInfo& repositoryInfo,
|
|
GetPackageInfosCallback callback, void* context) const;
|
|
|
|
private:
|
|
BEntry fEntry;
|
|
BRepositoryInfo fInfo;
|
|
bool fIsUserSpecific;
|
|
};
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
#endif // _PACKAGE__REPOSITORY_CACHE_H_
|