diff options
author | Justin Clark-Casey (justincc) | 2011-07-08 22:53:19 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-07-08 22:53:19 +0100 |
commit | c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4 (patch) | |
tree | 0e7050a1e23cb9f1bf3ffd23408fcea847ef91ee /OpenSim/Framework | |
parent | stop the local inventory services connector from logging an error when an ite... (diff) | |
download | opensim-SC-c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4.zip opensim-SC-c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4.tar.gz opensim-SC-c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4.tar.bz2 opensim-SC-c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4.tar.xz |
When loading library asset set, only store an asset if it's different from an existing one with the same id.
We compare existing and loaded asset by doing an SHA1 on both, so that a changed library asset will still update the store.
This cuts asset library load time from 10 seconds to <1 sec.
Note, a fix on the previous commit revealed a bug where a library script cannot be copied except on the first login after a cache clear.
This is unrelated to this commit and needs to be fixed at some subsequent time.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Util.cs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 039b926..fce8999 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -440,20 +440,30 @@ namespace OpenSim.Framework | |||
440 | } | 440 | } |
441 | 441 | ||
442 | /// <summary> | 442 | /// <summary> |
443 | /// Return an SHA1 hash of the given string | 443 | /// Return an SHA1 hash |
444 | /// </summary> | 444 | /// </summary> |
445 | /// <param name="data"></param> | 445 | /// <param name="data"></param> |
446 | /// <returns></returns> | 446 | /// <returns></returns> |
447 | public static string SHA1Hash(string data) | 447 | public static string SHA1Hash(string data) |
448 | { | 448 | { |
449 | return SHA1Hash(Encoding.Default.GetBytes(data)); | ||
450 | } | ||
451 | |||
452 | /// <summary> | ||
453 | /// Return an SHA1 hash | ||
454 | /// </summary> | ||
455 | /// <param name="data"></param> | ||
456 | /// <returns></returns> | ||
457 | public static string SHA1Hash(byte[] data) | ||
458 | { | ||
449 | byte[] hash = ComputeSHA1Hash(data); | 459 | byte[] hash = ComputeSHA1Hash(data); |
450 | return BitConverter.ToString(hash).Replace("-", String.Empty); | 460 | return BitConverter.ToString(hash).Replace("-", String.Empty); |
451 | } | 461 | } |
452 | 462 | ||
453 | private static byte[] ComputeSHA1Hash(string src) | 463 | private static byte[] ComputeSHA1Hash(byte[] src) |
454 | { | 464 | { |
455 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); | 465 | SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); |
456 | return SHA1.ComputeHash(Encoding.Default.GetBytes(src)); | 466 | return SHA1.ComputeHash(src); |
457 | } | 467 | } |
458 | 468 | ||
459 | public static int fast_distance2d(int x, int y) | 469 | public static int fast_distance2d(int x, int y) |