Cleanup some code

This commit is contained in:
Kovid Goyal
2024-09-15 08:03:16 +05:30
parent 33e4a0f9cc
commit 7537fa00e4
2 changed files with 6 additions and 4 deletions

View File

@@ -203,7 +203,11 @@ func unescape_metadata_value(k, x string) (ans string) {
func encode_bytes(metadata map[string]string, payload []byte) string {
ans := strings.Builder{}
ans.Grow(2048)
enc_payload := ""
if len(payload) > 0 {
enc_payload = base64.StdEncoding.EncodeToString(payload)
}
ans.Grow(2048 + len(enc_payload))
ans.WriteString("\x1b]")
ans.WriteString(OSC_NUMBER)
ans.WriteString(";")
@@ -217,7 +221,7 @@ func encode_bytes(metadata map[string]string, payload []byte) string {
}
if len(payload) > 0 {
ans.WriteString(";")
ans.WriteString(base64.StdEncoding.EncodeToString(payload))
ans.WriteString(enc_payload)
}
ans.WriteString("\x1b\\")
return ans.String()

View File

@@ -222,8 +222,6 @@ func run_set_loop(opts *Options, args []string) (err error) {
return fmt.Errorf("Could not guess MIME type for %s use the --mime option to specify a MIME type", arg)
}
to_process[i] = inputs[i]
if to_process[i].is_stream {
}
}
return write_loop(to_process, opts)
}