for faster, more reliable translation, using larger buffers

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5824 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty
2003-12-30 12:06:25 +00:00
parent 1074cc24d5
commit 3f7e8e7395
+7 -7
View File
@@ -117,15 +117,15 @@ StyledEditView::GetStyledText(BPositionIO * stream)
fSuppressChanges = true; fSuppressChanges = true;
SetText(""); SetText("");
fSuppressChanges = false; fSuppressChanges = false;
char inBuffer[256]; char inBuffer[32768];
off_t location = 0; off_t location = 0;
int32 textOffset = 0; int32 textOffset = 0;
int32 state = 0; int32 state = 0;
int32 bytesRead; int32 bytesRead;
while ((bytesRead = stream->ReadAt(location,inBuffer,256)) > 0) { while ((bytesRead = stream->ReadAt(location,inBuffer,32768)) > 0) {
char * inPtr = inBuffer; char * inPtr = inBuffer;
char textBuffer[256]; char textBuffer[32768];
int32 textLength = 256; int32 textLength = 32768;
int32 bytes = bytesRead; int32 bytes = bytesRead;
while ((textLength > 0) && (bytes > 0)) { while ((textLength > 0) && (bytes > 0)) {
result = convert_to_utf8(id,inPtr,&bytes,textBuffer,&textLength,&state); result = convert_to_utf8(id,inPtr,&bytes,textBuffer,&textLength,&state);
@@ -141,7 +141,7 @@ StyledEditView::GetStyledText(BPositionIO * stream)
bytesRead -= bytes; bytesRead -= bytes;
bytes = bytesRead; bytes = bytesRead;
if (textLength > 0) { if (textLength > 0) {
textLength = 256; textLength = 32768;
} }
} }
} }
@@ -176,10 +176,10 @@ StyledEditView::WriteStyledEditFile(BFile * file)
const char * outText = Text(); const char * outText = Text();
int32 sourceLength = TextLength(); int32 sourceLength = TextLength();
int32 state = 0; int32 state = 0;
char buffer[256]; char buffer[32768];
while (sourceLength > 0) { while (sourceLength > 0) {
int32 length = sourceLength; int32 length = sourceLength;
int32 written = 256; int32 written = 32768;
result = convert_from_utf8(id,outText,&length,buffer,&written,&state); result = convert_from_utf8(id,outText,&length,buffer,&written,&state);
if (result != B_OK) { if (result != B_OK) {
return result; return result;