XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

  1. static inline void xc_calc_string_n(xc_processor_t *processor, zend_uchar type, const_zstr str, long size RELAYLINE_DC TSRMLS_DC) { /* {{{ */
  2. pushdef(`PROCESSOR_TYPE', `calc')
  3. pushdef(`__LINE__', `relayline')
  4. size_t realsize = UNISW(size, (type == IS_UNICODE) ? UBYTES(size) : size);
  5. long dummy = 1;
  6. if (realsize > MAX_DUP_STR_LEN) {
  7. ALLOC(, char, realsize)
  8. }
  9. else if (zend_u_hash_add(&processor->strings, type, str, (uint) size, (void *) &dummy, sizeof(dummy), NULL) == SUCCESS) {
  10. /* new string */
  11. ALLOC(, char, realsize)
  12. }
  13. IFAUTOCHECK(`
  14. else {
  15. dnl fprintf(stderr, "dupstr %s\n", ZSTR_S(str));
  16. }
  17. ')
  18. popdef(`__LINE__')
  19. popdef(`PROCESSOR_TYPE')
  20. }
  21. /* }}} */
  22. static inline zstr xc_store_string_n(xc_processor_t *processor, zend_uchar type, const_zstr str, long size RELAYLINE_DC) { /* {{{ */
  23. pushdef(`PROCESSOR_TYPE', `store')
  24. pushdef(`__LINE__', `relayline')
  25. size_t realsize = UNISW(size, (type == IS_UNICODE) ? UBYTES(size) : size);
  26. zstr ret, *pret;
  27. if (realsize > MAX_DUP_STR_LEN) {
  28. ALLOC(ZSTR_V(ret), char, realsize)
  29. memcpy(ZSTR_V(ret), ZSTR_V(str), realsize);
  30. return ret;
  31. }
  32. if (zend_u_hash_find(&processor->strings, type, str, (uint) size, (void **) &pret) == SUCCESS) {
  33. TRACE("found old string %s:%ld %p", str, size, *pret);
  34. return *pret;
  35. }
  36. /* new string */
  37. ALLOC(ZSTR_V(ret), char, realsize)
  38. memcpy(ZSTR_V(ret), ZSTR_V(str), realsize);
  39. zend_u_hash_add(&processor->strings, type, str, (uint) size, (void *) &ret, sizeof(zstr), NULL);
  40. TRACE("stored new string %s:%ld %p", str, size, ret);
  41. return ret;
  42. popdef(`__LINE__')
  43. popdef(`PROCESSOR_TYPE')
  44. }
  45. /* }}} */