<commit_before>import React, {PropTypes} from 'react'
import canvasRenderer from '../canvasRenderer'
import {combineMatrices} from '../matrixUtil'

class GameCanvas extends React.Component {
  componentDidMount () {
    this.drawCanvas()
  }

  componentDidUpdate () {
    this.drawCanvas()
  }

  drawCanvas () {
    const canvas = this.refs.canvas
    if (canvas) {
      const context = canvas.getContext('2d')
      canvasRenderer.drawGame(context, this.props.board, this.props.currentPiece)
    }
  }

  render () {
    return (
      <canvas ref='canvas' id='game' width={this.props.width} height={this.props.height}>
        {
          combineMatrices(this.props.board, this.props.currentPiece.matrix).map((row, y) => ('| ' + row.join(' ') + ' |'))
        }
      </canvas>
    )
  }
}

GameCanvas.propTypes = {
  currentPiece: PropTypes.object.isRequired,
  board: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)).isRequired,
  width: PropTypes.number.isRequired,
  height: PropTypes.number.isRequired
}
export default GameCanvas
<commit_msg>Debounced draw calls<commit_after>import React, {PropTypes} from 'react'
import canvasRenderer from '../canvasRenderer'
import {combineMatrices} from '../matrixUtil'

class GameCanvas extends React.Component {
  componentDidMount () {
    this.drawCanvas()
  }

  componentDidUpdate () {
    this.drawCanvas()
  }

  drawCanvas () {
    const canvas = this.refs.canvas
    if (canvas) {
      const context = canvas.getContext('2d')
      if (!this.frameRequest) {
        this.frameRequest = window.requestAnimationFrame(() => {
          canvasRenderer.drawGame(context, this.props.board, this.props.currentPiece)
          this.frameRequest = undefined;
        })
      }
    }
  }

  render () {
    return (
      <canvas ref='canvas' id='game' width={this.props.width} height={this.props.height}>
        {
          combineMatrices(this.props.board, this.props.currentPiece.matrix).map((row, y) => ('| ' + row.join(' ') + ' |'))
        }
      </canvas>
    )
  }
}

GameCanvas.propTypes = {
  currentPiece: PropTypes.object.isRequired,
  board: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)).isRequired,
  width: PropTypes.number.isRequired,
  height: PropTypes.number.isRequired
}
export default GameCanvas

{'fraction_non_alphanumeric': 0.138353765323993, 'fraction_numerical': 0.0008756567425569177, 'mean_word_length': 3.263059701492537, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4486558', 'n_tokens_mistral': 697, 'n_tokens_neox': 699, 'n_words': 122}