diff options
author | UbitUmarov | 2018-02-25 00:18:41 +0000 |
---|---|---|
committer | UbitUmarov | 2018-02-25 00:18:41 +0000 |
commit | 85b973ce1d8dc034546c9c572a7f57e73b6017d3 (patch) | |
tree | a03332d9233e3788f8bc2e535b6863d8fe195b0b /OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs | |
parent | Yengine fix its section name on opensim.ini.example (diff) | |
download | opensim-SC-85b973ce1d8dc034546c9c572a7f57e73b6017d3.zip opensim-SC-85b973ce1d8dc034546c9c572a7f57e73b6017d3.tar.gz opensim-SC-85b973ce1d8dc034546c9c572a7f57e73b6017d3.tar.bz2 opensim-SC-85b973ce1d8dc034546c9c572a7f57e73b6017d3.tar.xz |
Y(xmr)engine cosmetics...
Diffstat (limited to 'OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs | 64 |
1 files changed, 20 insertions, 44 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs index b797224..3d0525b 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs | |||
@@ -108,10 +108,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
108 | { | 108 | { |
109 | key = FixKey(key); | 109 | key = FixKey(key); |
110 | 110 | ||
111 | /* | 111 | // Update heap use throwing an exception on failure |
112 | * Update heap use throwing an exception on failure | 112 | // before making any changes to the array. |
113 | * before making any changes to the array. | ||
114 | */ | ||
115 | int keysize = HeapTrackerObject.Size(key); | 113 | int keysize = HeapTrackerObject.Size(key); |
116 | int newheapuse = heapUse; | 114 | int newheapuse = heapUse; |
117 | object oldval; | 115 | object oldval; |
@@ -125,10 +123,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
125 | } | 123 | } |
126 | heapUse = inst.UpdateHeapUse(heapUse, newheapuse); | 124 | heapUse = inst.UpdateHeapUse(heapUse, newheapuse); |
127 | 125 | ||
128 | /* | 126 | // Save new value in array, replacing one of same key if there. |
129 | * Save new value in array, replacing one of same key if there. | 127 | // null means remove the value, ie, script did array[key] = undef. |
130 | * null means remove the value, ie, script did array[key] = undef. | ||
131 | */ | ||
132 | if(value != null) | 128 | if(value != null) |
133 | { | 129 | { |
134 | dnary[key] = value; | 130 | dnary[key] = value; |
@@ -137,19 +133,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
137 | { | 133 | { |
138 | dnary.Remove(key); | 134 | dnary.Remove(key); |
139 | 135 | ||
140 | /* | 136 | // Shrink the enumeration array, but always leave at least one element. |
141 | * Shrink the enumeration array, but always leave at least one element. | ||
142 | */ | ||
143 | if((array != null) && (dnary.Count < array.Length / 2)) | 137 | if((array != null) && (dnary.Count < array.Length / 2)) |
144 | { | 138 | { |
145 | Array.Resize<KeyValuePair<object, object>>(ref array, array.Length / 2); | 139 | Array.Resize<KeyValuePair<object, object>>(ref array, array.Length / 2); |
146 | } | 140 | } |
147 | } | 141 | } |
148 | 142 | ||
149 | /* | 143 | // The enumeration array is invalid because the dictionary has been modified. |
150 | * The enumeration array is invalid because the dictionary has been modified. | 144 | // Next time a ForEach() call happens, it will repopulate 'array' as elements are retrieved. |
151 | * Next time a ForEach() call happens, it will repopulate 'array' as elements are retrieved. | ||
152 | */ | ||
153 | arrayValid = 0; | 145 | arrayValid = 0; |
154 | } | 146 | } |
155 | 147 | ||
@@ -236,29 +228,23 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
236 | */ | 228 | */ |
237 | private bool ForEach(int number) | 229 | private bool ForEach(int number) |
238 | { | 230 | { |
239 | /* | 231 | // If we don't have any array, we can't have ever done |
240 | * If we don't have any array, we can't have ever done | 232 | // any calls here before, so allocate an array big enough |
241 | * any calls here before, so allocate an array big enough | 233 | // and set everything else to the beginning. |
242 | * and set everything else to the beginning. | ||
243 | */ | ||
244 | if(array == null) | 234 | if(array == null) |
245 | { | 235 | { |
246 | array = new KeyValuePair<object, object>[dnary.Count]; | 236 | array = new KeyValuePair<object, object>[dnary.Count]; |
247 | arrayValid = 0; | 237 | arrayValid = 0; |
248 | } | 238 | } |
249 | 239 | ||
250 | /* | 240 | // If dictionary modified since last enumeration, get a new enumerator. |
251 | * If dictionary modified since last enumeration, get a new enumerator. | ||
252 | */ | ||
253 | if(arrayValid == 0) | 241 | if(arrayValid == 0) |
254 | { | 242 | { |
255 | enumr = dnary.GetEnumerator(); | 243 | enumr = dnary.GetEnumerator(); |
256 | enumrValid = true; | 244 | enumrValid = true; |
257 | } | 245 | } |
258 | 246 | ||
259 | /* | 247 | // Make sure we have filled the array up enough for requested element. |
260 | * Make sure we have filled the array up enough for requested element. | ||
261 | */ | ||
262 | while((arrayValid <= number) && enumrValid && enumr.MoveNext()) | 248 | while((arrayValid <= number) && enumrValid && enumr.MoveNext()) |
263 | { | 249 | { |
264 | if(arrayValid >= array.Length) | 250 | if(arrayValid >= array.Length) |
@@ -268,9 +254,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
268 | array[arrayValid++] = enumr.Current; | 254 | array[arrayValid++] = enumr.Current; |
269 | } | 255 | } |
270 | 256 | ||
271 | /* | 257 | // If we don't have that many elements, return end-of-array status. |
272 | * If we don't have that many elements, return end-of-array status. | ||
273 | */ | ||
274 | return number < arrayValid; | 258 | return number < arrayValid; |
275 | } | 259 | } |
276 | 260 | ||
@@ -281,10 +265,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
281 | public delegate void SendArrayObjDelegate(object graph); | 265 | public delegate void SendArrayObjDelegate(object graph); |
282 | public void SendArrayObj(SendArrayObjDelegate sendObj) | 266 | public void SendArrayObj(SendArrayObjDelegate sendObj) |
283 | { | 267 | { |
284 | /* | 268 | // Set the count then the elements themselves. |
285 | * Set the count then the elements themselves. | 269 | // UnfixKey() because sendObj doesn't handle XMRArrayListKeys. |
286 | * UnfixKey() because sendObj doesn't handle XMRArrayListKeys. | ||
287 | */ | ||
288 | sendObj(dnary.Count); | 270 | sendObj(dnary.Count); |
289 | foreach(KeyValuePair<object, object> kvp in dnary) | 271 | foreach(KeyValuePair<object, object> kvp in dnary) |
290 | { | 272 | { |
@@ -304,17 +286,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
304 | { | 286 | { |
305 | heapUse = inst.UpdateHeapUse(heapUse, EMPTYHEAP); | 287 | heapUse = inst.UpdateHeapUse(heapUse, EMPTYHEAP); |
306 | 288 | ||
307 | /* | 289 | // Cause any enumeration to refill the array from the sorted dictionary. |
308 | * Cause any enumeration to refill the array from the sorted dictionary. | 290 | // Since it is a sorted dictionary, any enumerations will be in the same |
309 | * Since it is a sorted dictionary, any enumerations will be in the same | 291 | // order as on the sending side. |
310 | * order as on the sending side. | ||
311 | */ | ||
312 | arrayValid = 0; | 292 | arrayValid = 0; |
313 | enumrValid = false; | 293 | enumrValid = false; |
314 | 294 | ||
315 | /* | 295 | // Fill dictionary. |
316 | * Fill dictionary. | ||
317 | */ | ||
318 | dnary.Clear(); | 296 | dnary.Clear(); |
319 | int count = (int)recvObj(); | 297 | int count = (int)recvObj(); |
320 | while(--count >= 0) | 298 | while(--count >= 0) |
@@ -375,9 +353,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
375 | */ | 353 | */ |
376 | public int Compare(object x, object y) // IComparer<object> | 354 | public int Compare(object x, object y) // IComparer<object> |
377 | { | 355 | { |
378 | /* | 356 | // Use short type name (eg, String, Int32, XMRArrayListKey) as most significant part of key. |
379 | * Use short type name (eg, String, Int32, XMRArrayListKey) as most significant part of key. | ||
380 | */ | ||
381 | string xtn = x.GetType().Name; | 357 | string xtn = x.GetType().Name; |
382 | string ytn = y.GetType().Name; | 358 | string ytn = y.GetType().Name; |
383 | int ctn = String.CompareOrdinal(xtn, ytn); | 359 | int ctn = String.CompareOrdinal(xtn, ytn); |