Просмотр исходного кода

* newsplit(String) now returns the last token

Bryan Drewery 17 лет назад
Родитель
Сommit
8226d139c0
2 измененных файлов с 3 добавлено и 21 удалено
  1. 1 1
      lib/bdlib
  2. 2 20
      src/EncryptedStream.c

+ 1 - 1
lib/bdlib

@@ -1 +1 @@
-Subproject commit 892bcf5134d9a274e292d0b1f67ea269595f4e35
+Subproject commit b451ae7b33d5f111b3e132cb6079d2779f13c5fd

+ 2 - 20
src/EncryptedStream.c

@@ -37,21 +37,12 @@ int EncryptedStream::loadFile (const int fd) {
 
   if (enc_flags & ENC_KEEP_NEWLINES) {
     bd::String buf(in_buf), line, out_buf;
-    /* terribly ineffecient, but this is used infrequently */
-    while (buf.find('\n') != bd::String::npos) {
+    while (buf.length()) {
       line = newsplit(buf, '\n');
       unapply_filters(line, enc_flags);
       line += '\n';
       out_buf += line;
     }
-
-    /* Finish the rest off */
-    if (buf.length()) {
-      line = buf;
-      unapply_filters(line, enc_flags);
-      line += '\n';
-      out_buf += line;
-    }
     in_buf = out_buf;
   } else {
     unapply_filters(in_buf, enc_flags);
@@ -95,22 +86,13 @@ int EncryptedStream::writeFile (const int fd, const char enc_flags) const {
 
   if (enc_flags & ENC_KEEP_NEWLINES) {
     bd::String buf(str), line;
-    /* terribly ineffecient, but this is used infrequently */
-    while (buf.find('\n') != bd::String::npos) {
+    while (buf.length()) {
       line = newsplit(buf, '\n');
       apply_filters(line, enc_flags);
       line += '\n';
       out_buf += line;
     }
 
-    /* Finish the rest off */
-    if (buf.length()) {
-      line = buf;
-      apply_filters(line, enc_flags);
-      line += '\n';
-      out_buf += line;
-    }
-
   } else {
     out_buf = str;
     apply_filters(out_buf, enc_flags);