Introduction
Introduction Statistics Contact Development Disclaimer Help
sfeed_content: optimizations - sfeed_curses - sfeed curses UI (now part of sfee…
git clone git://git.codemadness.org/sfeed_curses
Log
Files
Refs
README
LICENSE
---
commit 8e151ce48b503ad0ff0e24cb1be3bc93d6fbd895
parent 7bf22e2b26d6e81c28404cc0230b7a0b6dee54c3
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 25 Oct 2021 22:59:20 +0200
sfeed_content: optimizations
- Optimize the unescape() function. Use a temporary replacement character so
escaping escape codes work correctly. The \x01 character cannot occur in the
sfeed(5) data.
- Optimize text decoding in gawk and other awk implementations that support
unicode. This forces a simpler byte decoding and increases performance. This
works because the sfeed(5) data is UTF-8.
Diffstat:
M sfeed_content | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/sfeed_content b/sfeed_content
@@ -1,21 +1,15 @@
#!/bin/sh
# Content viewer for sfeed(5) lines.
-awk -F '\t' '
+# The locale is set to "C" for performance. The input is always UTF-8.
+LC_ALL=C awk -F '\t' '
function unescape(s) {
- for (data = ""; (idx = index(s, "\\")); s = substr(s, idx + 2)) {
- prev = substr(s, 1, idx - 1)
- c = substr(s, idx + 1, 1)
- if (c == "t")
- data = data prev "\t"
- else if (c == "n")
- data = data prev "\n"
- else if (c == "\\")
- data = data prev "\\"
- else
- data = data prev # ignore other.
- }
- return data s # rest
+ # use the character "\x01" as a temporary replacement for "\".
+ gsub("\\\\\\\\", "\x01", s);
+ gsub("\\\\n", "\n", s);
+ gsub("\\\\t", "\t", s);
+ gsub("\x01", "\\", s); # restore "\x01" to "\".
+ return s;
}
BEGIN {
htmlconv = "lynx -stdin -dump " \
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.