Raised This Month: $51 Target: $400
 12% 

Direct Parameters in ArraySort() Callback


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 09-23-2012 , 10:17   Direct Parameters in ArraySort() Callback
Reply With Quote #1

It's more of a request, which, if granted, would increase the performance of the callback function passed in ArraySort().

An example plugin:
Code:
#include <amxmodx> public plugin_init() {     new Array:array = ArrayCreate(32);     FillArrayWithRandomValues(array); // Irrelevant     ArraySort(array, "OnSortArray");     ArrayDestroy(array); } public OnSortArray(Array:array, item1, item2) {     static value1[32], value2[32];     ArrayGetArray(array, item1, value1);     ArrayGetArray(array, item2, value2);         return GetSortReturnValue(value1, value2); // Irrelevant }
Now everytime OnSortArray() is called, ArrayGetArray() is called twice. It becomes a very expensive operation when there are thousands of entries in the array to sort.

What I want to suggest is to directly pass the values of currently sorted array items rather than their positions in the array. So it would become:
Code:
public OnSortArray(Array:array, const value1[], const value2[]) {     return GetSortReturnValue(value1, value2); // Irrelevant }
That should be possible, right? One array can only hold either cells, strings or arrays, so there wouldn't be problems with deciding what kind of parameters to pass into the callback.

This would be useful for both AMX Mod X & SourceMod.
hleV is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 09-23-2012 , 14:54   Re: Direct Parameters in ArraySort() Callback
Reply With Quote #2

Then why not go submit this as a Feature Request in the Bug Tracker?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 09-23-2012 , 16:13   Re: Direct Parameters in ArraySort() Callback
Reply With Quote #3

Fair enough.

Though I can't seem to find this Feature Request. Everything there seems to imply that I'm reporting a bug.
hleV is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 09-23-2012 , 16:19   Re: Direct Parameters in ArraySort() Callback
Reply With Quote #4

In some sense you are reporting a bug, as the feature is missing.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode