Added serializer precompile to preload step for kdbp files

This commit is contained in:
AlexVallat 2013-08-15 18:49:27 +01:00
parent 4cbc4542c2
commit bb0827ea51
2 changed files with 14 additions and 0 deletions

View File

@ -15,6 +15,14 @@ namespace KeePassLib.Serialization
{
public const string FileNameExtension = "kdbp";
/// <summary>
/// Precompiles the serializer classes for faster first-run execution
/// </summary>
public static void PrepareSerializer()
{
RuntimeTypeModel.Default[typeof(PwDatabaseBuffer)].CompileInPlace();
}
/// <summary>
/// Determines whether the database pointed to by the specified ioc should be (de)serialised in default (xml) or protocol buffers format.
/// </summary>

View File

@ -375,6 +375,12 @@ namespace keepass2android
private MemoryStream LoadDbFile()
{
if (KdbpFile.GetFormatToUse(_ioConnection) == KdbxFormat.ProtocolBuffers)
{
Kp2aLog.Log("Preparing kdbp serializer");
KdbpFile.PrepareSerializer();
}
Kp2aLog.Log("Pre-loading database file starting");
var fileStorage = App.Kp2a.GetFileStorage(_ioConnection);
var stream = fileStorage.OpenFileForRead(_ioConnection);