Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cookies  RSS feed

 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thanks a lot in advance.
I am facing some problem with cookies, please help me,
I have added some cookies and want to retrieve latest three from them. If I start comparing each then there will be performance hit.
What to do?

Regards,
Sree
 
sridhar ponnusamy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use Arrays.binarySearch(Object[] a, Object key); ..if it matches your requirements.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by sridhar ponnusamy:
use Arrays.binarySearch(Object[] a, Object key); ..if it matches your requirements.


But is the object returned from request.getKookies() sorted?
You need a sorted array/collection before you could apply binary search on that. Generally as I see, complete object array returned from request.getKookies() is traversed to get the required cookie object.
Depends how long the object array is, and how early you get desired cookie, from that array to quit from the loop.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Performance hit? How so? Comparisons are quick and easy unless you are talking about thousands of them. Are you victim of premature optimization?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given all the time consuming network operations and computation involved in receiving a request, I would be highly surprised if you could even measure the time consumed in searching cookies text by any method. Go for something easy to explain and document.

Bill
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam not getting this sentence meening "Go for something easy to explain and document"
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than stressing about a solution, write something atht doesn't suck too badly and provide comments. Our point is that as long as you aren't too wild and carefree in your code, it is unlikely to be as bad as you believe.

And comment the expected behaviour so someone can fix it if there is a problem afterwards.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you should consider making your subject line more meaningful. "Cookies" is too small to make out.Read this to know why.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!