Skip to content

Commit ce19ea3

Browse files
committed
Use array tuple keys for style_func map
Replace string keys like "0,1" with [0, 1] array tuples in the style_func precomputed map. Avoids string allocation per lookup and is more idiomatic Ruby.
1 parent 8b1a914 commit ce19ea3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/lipgloss/table.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ def style_func(rows:, columns:, &block)
6969
# Header row
7070
columns.times do |column|
7171
style = block.call(HEADER_ROW, column)
72-
style_map["#{HEADER_ROW},#{column}"] = style if style
72+
style_map[[HEADER_ROW, column]] = style if style
7373
end
7474

7575
# Data rows
7676
rows.times do |row_idx|
7777
columns.times do |column|
7878
style = block.call(row_idx, column)
79-
style_map["#{row_idx},#{column}"] = style if style
79+
style_map[[row_idx, column]] = style if style
8080
end
8181
end
8282

@@ -210,7 +210,7 @@ def build_data_row(row_data, col_widths, chars, row_idx)
210210

211211
# Apply style_func if available
212212
if @style_map
213-
style = @style_map["#{row_idx},#{i}"]
213+
style = @style_map[[row_idx, i]]
214214
cell_text = style.render(cell_text) if style
215215
end
216216

0 commit comments

Comments
 (0)