Casting overhead reduction with hashCode()-like function in Java -


this function have call many many times per milliseconds. how can reduce price of downcasting and/or price of other operation in particular line?

public int convertstringtonodeint(string string){         int n = string.length();         int temp = 1;         for(int i=1; i<n; i++){             temp += (int)math.pow(4, i);         }         for(int i=1; i<=n; i++){  -->->->    temp += ((int)math.pow(4, n-i))*((int)string.charat(i-1)-65); <-<-<--         }         return temp;     } } 

basically converts "a" 1, "b" 2, "aa" 5, "bac" 39.

i using hash function store objects in array, depending on key string. (only 1 object 1 key) it's representing quadtree.

i think cause of overhead, downcasting of double , conversion of character int (whatever kind of casting is)..

can me if there workaround? (i can't test yet, when whole program done)

// i'm curious if there better way store nodes of quadtree, came idea , algorithm myself , far it.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -