bug 164278, reading cookie file is inefficient, c=brade, r=morse, sr=darin
git-svn-id: svn://10.0.0.236/trunk@128402 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
453adc546e
commit
30717f5ad9
@ -1698,7 +1698,11 @@ COOKIE_Read() {
|
||||
* expires is a time_t integer
|
||||
* cookie can have tabs
|
||||
*/
|
||||
while (CKutil_GetLine(strm,buffer) != -1){
|
||||
|
||||
#define BUFSIZE 4096
|
||||
char readbuffer[BUFSIZE];
|
||||
PRInt32 next = BUFSIZE, count = BUFSIZE;
|
||||
while (CKutil_GetLine(strm, readbuffer, BUFSIZE, next, count, buffer) != -1){
|
||||
added_to_list = PR_FALSE;
|
||||
|
||||
if ( !buffer.IsEmpty() ) {
|
||||
|
||||
@ -476,7 +476,11 @@ PERMISSION_Read() {
|
||||
* host \t number permission \t number permission ... \n
|
||||
* if this format isn't respected we move onto the next line in the file.
|
||||
*/
|
||||
while(CKutil_GetLine(strm,buffer) != -1) {
|
||||
|
||||
#define BUFSIZE 4096
|
||||
char readbuffer[BUFSIZE];
|
||||
PRInt32 next = BUFSIZE, count = BUFSIZE;
|
||||
while(CKutil_GetLine(strm, readbuffer, BUFSIZE, next, count, buffer) != -1) {
|
||||
if ( !buffer.IsEmpty() ) {
|
||||
char firstChar = buffer.CharAt(0);
|
||||
if (firstChar == '#' || firstChar == nsCRT::CR ||
|
||||
|
||||
@ -47,25 +47,25 @@
|
||||
|
||||
static NS_DEFINE_IID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
|
||||
#define BUFSIZE 128
|
||||
#define LOCALIZATION "chrome://cookie/locale/cookie.properties"
|
||||
|
||||
nsresult
|
||||
ckutil_getChar(nsInputFileStream& strm, char& c) {
|
||||
static char buffer[BUFSIZE];
|
||||
static PRInt32 next = BUFSIZE, count = BUFSIZE;
|
||||
ckutil_getChar(nsInputFileStream& strm,
|
||||
char *buffer, PRInt32 bufsize,
|
||||
PRInt32& next, PRInt32& count,
|
||||
char& c) {
|
||||
|
||||
if (next == count) {
|
||||
if (BUFSIZE > count) { // never say "count < ..." vc6.0 thinks this is a template beginning and crashes
|
||||
next = BUFSIZE;
|
||||
count = BUFSIZE;
|
||||
if (bufsize > count) { // never say "count < ..." vc6.0 thinks this is a template beginning and crashes
|
||||
next = bufsize;
|
||||
count = bufsize;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
count = strm.read(buffer, BUFSIZE);
|
||||
count = strm.read(buffer, bufsize);
|
||||
next = 0;
|
||||
if (count == 0) {
|
||||
next = BUFSIZE;
|
||||
count = BUFSIZE;
|
||||
next = bufsize;
|
||||
count = bufsize;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
@ -79,13 +79,14 @@ ckutil_getChar(nsInputFileStream& strm, char& c) {
|
||||
* strip carriage returns and line feeds from end of line
|
||||
*/
|
||||
PUBLIC PRInt32
|
||||
CKutil_GetLine(nsInputFileStream& strm, nsACString& aLine) {
|
||||
CKutil_GetLine(nsInputFileStream& strm, char *buffer, PRInt32 bufsize,
|
||||
PRInt32& next, PRInt32& count, nsACString& aLine) {
|
||||
|
||||
/* read the line */
|
||||
aLine.Truncate();
|
||||
char c;
|
||||
for (;;) {
|
||||
if NS_FAILED(ckutil_getChar(strm, c)) {
|
||||
if NS_FAILED(ckutil_getChar(strm, buffer, bufsize, next, count, c)) {
|
||||
return -1;
|
||||
}
|
||||
if (c == '\n') {
|
||||
|
||||
@ -42,7 +42,8 @@
|
||||
#include "nsString.h"
|
||||
#include "nsFileStream.h"
|
||||
|
||||
extern PRInt32 CKutil_GetLine(nsInputFileStream& strm, nsACString& aLine);
|
||||
extern PRInt32 CKutil_GetLine(nsInputFileStream& strm, char *aBuf, PRInt32 sz,
|
||||
PRInt32& next, PRInt32& count, nsACString& aLine);
|
||||
extern PRUnichar* CKutil_Localize(const PRUnichar *genericString);
|
||||
extern nsresult CKutil_ProfileDirectory(nsFileSpec& dirSpec);
|
||||
extern char * CKutil_StrAllocCopy(char *&destination, const char *source);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user